Create an instance of Maybe.Just
.
The value to wrap in a Maybe.Just
.
An instance of Maybe.Just<T>
.
Create an instance of Maybe.Nothing
.
If you want to create an instance with a specific type, e.g. for use in a
function which expects a Maybe<T>
where the <T>
is known but you have no
value to give it, you can use a type parameter:
const notString = Maybe.nothing<string>();
Optional
_: nullAn instance of Maybe.Nothing<T>
.
Create a Maybe
from any value.
To specify that the result should be interpreted as a specific type, you may
invoke Maybe.of
with an explicit type parameter:
const foo = Maybe.of<string>(null);
This is usually only important in two cases:
Nothing
from a known null
or
undefined value which is untyped.The value to wrap in a Maybe
. If it is undefined
or null
,
the result will be Nothing
; otherwise it will be the type of
the value passed.
The public interface for the
Maybe
class as a value: a constructor and the associated static properties.