Maybe
Functions
map

Transforms a maybe value by using the specified mapping function.

Type Signature
((a) -> b, maybe<a>) -> maybe<b>
Parameters
f : (a) -> b

The mapping function

maybeVal : maybe<a>

The maybe value

Returns

The transformed maybe value.

get

Returns the value associated with the maybe or crashes the program.

Type Signature
(maybe<a>) -> a
Parameters
maybeVal : maybe<a>

The maybe value

Returns

The value inside of the maybe.

isJust

Returns true if the maybe value is not nothing

Type Signature
(maybe<a>) -> bool
Parameters
maybeVal : maybe<a>

The maybe value

Returns

true if the maybe value is not nothing, false otherwise

isNothing

Returns true if the maybe value is nothing

Type Signature
(maybe<a>) -> bool
Parameters
maybeVal : maybe<a>

The maybe value

Returns

true if the maybe value is nothing, false otherwise.

count

Returns 0 if the maybe value is nothing, 1 otherwise

Type Signature
(maybe<a>) -> uint8
Parameters
maybeVal : maybe<a>

The maybe value

Returns

The number of items stored in the count

fold

Evaluates the equivalent of List:fold for a maybe

Type Signature
((t, state) -> state, state, maybe<t>) -> state
Parameters
f : (t, state) -> state

The folding function

initState : state

The initial state

maybeVal : maybe<t>

The maybe value

Returns

The final state returned by f, or initState if the maybe was nothing()

iter

Executes a function for a maybe value for the purpose of a side effect.

Type Signature
((a) -> unit, maybe<a>) -> unit
Parameters
f : (a) -> unit

The function to apply to the value

maybeVal : maybe<a>

The maybe value

Returns

unit