Skip to main content

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​

NameType
Monadextends 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​

NameType
Monadextends Maybe<any>
NextValueNextValue

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​

NameType
mapMap<Value, Maybe<NextValue>>

Returns​

fn

▸ (monad): Maybe<NextValue>

Parameters​
NameType
monadMaybe<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​

NameType
monadMaybe<Value>
mapMap<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​

NameType
mapMap<Value, NextValue>

Returns​

fn

▸ (monad): Maybe<NonNullable<NextValue>>

Parameters​
NameType
monadMaybe<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​

NameType
monadMaybe<Value>
mapMap<Value, NextValue>

Returns​

Maybe<NonNullable<NextValue>>


fold​

▸ fold<Monad>(monad): Fold<Monad>

Returns the value of the provided monad.

Type parameters​

NameType
Monadextends Just<any>

Parameters​

NameType
monadMonad

Returns​

Fold<Monad>

▸ fold<Value>(monad): Value | undefined

Returns the value of the provided monad.

Type parameters​

Name
Value

Parameters​

NameType
monadMaybe<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​

NameType
mapMap<Value, NextValue>

Returns​

fn

▸ (monad): NextValue | undefined

Parameters​
NameType
monadMaybe<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​

NameType
monadMaybe<Value>
mapMap<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​

NameType
valueany

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​

NameType
valueany

Returns​

value is Maybe<Value>


isNothing​

▸ isNothing(value): value is Nothing

Type guard function to tell if the provided value is Nothing.

Parameters​

NameType
valueany

Returns​

value is Nothing