Module: Maybe Operators
Type Aliases
Fold
Ƭ Fold<Monad
>: Monad
extends Just
<infer Value> ? Value
: Monad
extends Nothing
? undefined
: Monad
extends Maybe
<infer Value> ? Value
| undefined
: never
A type to unwrap the value type of the provided Monad
.
Type parameters
Name | Type |
---|---|
Monad | extends Maybe <any > |
FoldMap
Ƭ FoldMap<Monad
, NextValue
>: Monad
extends Just
<any
> ? NextValue
: Monad
extends Nothing
? undefined
: Monad
extends Maybe
<any
> ? NextValue
| undefined
: never
A type to unwrap the provided Monad
into the new value type.
Type parameters
Name | Type |
---|---|
Monad | extends Maybe <any > |
NextValue | NextValue |
Functions
bind
▸ bind<Value
, NextValue
>(map
): (monad
: Maybe
<Value
>) => Maybe
<NextValue
>
Binds the value of the monad
to new monad created
by the transition
function.
Type parameters
Name |
---|
Value |
NextValue |
Parameters
Name | Type |
---|---|
map | Map <Value , Maybe <NextValue >> |
Returns
fn
▸ (monad
): Maybe
<NextValue
>
Parameters
Name | Type |
---|---|
monad | Maybe <Value > |
Returns
Maybe
<NextValue
>
▸ bind<Value
, NextValue
>(monad
, map
): Maybe
<NextValue
>
Binds the value of the monad
to new monad created
by the transition
function.
Type parameters
Name |
---|
Value |
NextValue |
Parameters
Name | Type |
---|---|
monad | Maybe <Value > |
map | Map <Value , Maybe <NextValue >> |
Returns
Maybe
<NextValue
>
fmap
▸ fmap<Value
, NextValue
>(map
): (monad
: Maybe
<Value
>) => Maybe
<NonNullable
<NextValue
>>
Maps the value of the provided monad
through the transition
function
and returns a new Maybe
of the mapped value.
Type parameters
Name |
---|
Value |
NextValue |
Parameters
Name | Type |
---|---|
map | Map <Value , NextValue > |
Returns
fn
▸ (monad
): Maybe
<NonNullable
<NextValue
>>
Parameters
Name | Type |
---|---|
monad | Maybe <Value > |
Returns
Maybe
<NonNullable
<NextValue
>>
▸ fmap<Value
, NextValue
>(monad
, map
): Maybe
<NonNullable
<NextValue
>>
Maps the value of the provided monad
through the transition
function
and returns a new Maybe
of the mapped value.
Type parameters
Name |
---|
Value |
NextValue |
Parameters
Name | Type |
---|---|
monad | Maybe <Value > |
map | Map <Value , NextValue > |
Returns
Maybe
<NonNullable
<NextValue
>>
fold
▸ fold<Monad
>(monad
): Fold
<Monad
>
Returns the value of the provided monad
.
Type parameters
Name | Type |
---|---|
Monad | extends Just <any > |
Parameters
Name | Type |
---|---|
monad | Monad |
Returns
Fold
<Monad
>
▸ fold<Value
>(monad
): Value
| undefined
Returns the value of the provided monad
.
Type parameters
Name |
---|
Value |
Parameters
Name | Type |
---|---|
monad | Maybe <Value > |
Returns
Value
| undefined
foldMap
▸ foldMap<Value
, NextValue
>(map
): (monad
: Maybe
<Value
>) => NextValue
| undefined
Maps the value of the provided monad
through the transition
function
and returns the mapped value or null
.
Type parameters
Name |
---|
Value |
NextValue |
Parameters
Name | Type |
---|---|
map | Map <Value , NextValue > |
Returns
fn
▸ (monad
): NextValue
| undefined
Parameters
Name | Type |
---|---|
monad | Maybe <Value > |
Returns
NextValue
| undefined
▸ foldMap<Value
, NextValue
>(monad
, map
): NextValue
| undefined
Maps the value of the provided monad
through the transition
function
and returns the mapped value or null
.
Type parameters
Name |
---|
Value |
NextValue |
Parameters
Name | Type |
---|---|
monad | Maybe <Value > |
map | Map <Value , NextValue > |
Returns
NextValue
| undefined
isJust
▸ isJust<Value
>(value
): value is Just<Value>
Type guard function to tell if the provided value
is Just
.
Type parameters
Name |
---|
Value |
Parameters
Name | Type |
---|---|
value | any |
Returns
value is Just<Value>
isMaybe
▸ isMaybe<Value
>(value
): value is Maybe<Value>
Type guard function to tell if the provided value
is Maybe
.
Type parameters
Name |
---|
Value |
Parameters
Name | Type |
---|---|
value | any |
Returns
value is Maybe<Value>
isNothing
▸ isNothing(value
): value is Nothing
Type guard function to tell if the provided value
is Nothing
.
Parameters
Name | Type |
---|---|
value | any |
Returns
value is Nothing