option

Carbon-copied Haskell's Maybe monad.

License:
  • Apache-2.0
Source:

Members

(static) JUST

No-value or value?

Source:

(inner, constant) NOTHING

No value - runtime domain.

Source:

(inner, constant) __maybe

'Maybe' type internal trait.

Source:

Methods

(inner) JUST(value)

Value - runtime domain. Monadic return.

Source:
Parameters:
Name Type Description
value
Returns:

Just

(inner) bind(ma, f)

Option monad - >>=;

If maybe has value then apply f to it and return result. Otherwise return NOTHING.

Source:
Parameters:
Name Type Description
ma
f

f: a -> mb

Returns:

(ma >>= f): mb

(inner) hasValue(maybe)

Type assertion - does that value of Maybe type have value?

Source:
Parameters:
Name Type Description
maybe
Returns:

boolean

(inner) optionalize(f)

Option monad - ap.

Takes regular function and makes it Maybe-compatible.

Source:
Parameters:
Name Type Description
f

f: a -> b

Returns:

mf: ma -> mb

(inner) rbind(f, ma)

Option monad - =<<;

If maybe has value then apply f to it and return result. Otherwise return NOTHING.

Source:
Parameters:
Name Type Description
f

f: a -> mb

ma
Returns:

(f =<< ma): mb