Carbon-copied Haskell's Maybe monad.
- Copyright:
- Mat. 2023-present
- License:
- Apache-2.0
- Source:
Members
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