Maybe

Summary
Maybe
Functions
mapTransforms a maybe value by using the specified mapping function.
getReturns the value associated with the maybe or crashes the program.
isJustReturns true if the maybe value is not nothing
isNothingReturns true if the maybe value is nothing
countReturns 0 if the maybe value is nothing, 1 otherwise
foldlEvaluates the equivalent of List:foldl for a maybe
foldrEvaluates the equivalent of List:foldr for a maybe
iterExecutes a function for a maybe value

Functions

map

Transforms a maybe value by using the specified mapping function.

Type signature

<'a,'b>(('a) -> 'b, maybe<'a>) -> maybe<'b>

Parameters

f : (‘a) -> ‘bThe 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

<'a>(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

<'a>(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

<'a>(maybe<'a>) -> bool

Parameters

maybeVal : maybe<’a>The maybe value

Returns

True if the maybe evalue is nothing, false otherwise.

count

Returns 0 if the maybe value is nothing, 1 otherwise

Type signature

<'a>(maybe<'a>) -> uint8

Parameters

maybeVal : maybe<’a>The maybe value

Returns

The number of items stored in the count

foldl

Evaluates the equivalent of List:foldl for a maybe

Type signature

<'t,'state>(('t, 'state) -> 'state, 'state, maybe<'t>) -> 'state

Parameters

f : (‘t, ‘state) -> ‘stateThe folding function
initState : ‘stateThe initial state
maybeVal : maybe<’t>The maybe value

Returns

The final state returned by f

foldr

Evaluates the equivalent of List:foldr for a maybe

Type signature

<'t,'state>(('t, 'state) -> 'state, 'state, maybe<'t>) -> 'state

Parameters

f : (‘t, ‘state) -> ‘stateThe folding function
initState : ‘stateThe initial state
maybeVal : maybe<’t>The maybe value

Returns

The final state returned by f

iter

Executes a function for a maybe value

Type signature

<'a>(('a) -> unit, maybe<'a>) -> unit

Parameters

f : (‘a) -> unitThe function to apply to the value
maybeVal : maybe<’a>The maybe value

Returns

Unit

Close