Skip to main content

Module: Either Operators

Type Aliases

Bifold

Ƭ Bifold<Monad>: Monad extends Left<infer LeftValue> ? LeftValue : Monad extends Right<infer RightValue> ? RightValue : Monad extends Either<infer LeftValue, infer RightValue> ? LeftValue | RightValue : never

A type to unwrap either the left or the right value type of the provided Monad.

Type parameters

NameType
Monadextends Either<any, any>

Bifoldl

Ƭ Bifoldl<Monad>: Monad extends Left<infer LeftValue> ? LeftValue : Monad extends Either<infer LeftValue, any> ? LeftValue | undefined : never

A type to unwrap the left value type of the provided Monad. If the Monad is Right, returns undefined.

Type parameters

NameType
Monadextends Either<any, any>

Bifoldr

Ƭ Bifoldr<Monad>: Monad extends Right<infer RightValue> ? RightValue : Monad extends Either<any, infer RightValue> ? RightValue | undefined : never

A type to unwrap the right value type of the provided Monad. If the Monad is Left, returns undefined.

Type parameters

NameType
Monadextends Either<any, any>

First

Ƭ First<Monad>: Monad extends Left<infer LeftValue> ? LeftValue : Monad extends Either<infer LeftValue, any> ? LeftValue : never

Type parameters

NameType
Monadextends Either<any, any>

Second

Ƭ Second<Monad>: Monad extends Right<infer RightValue> ? RightValue : Monad extends Either<any, infer RightValue> ? RightValue : never

Type parameters

NameType
Monadextends Either<any, any>

Functions

bifold

bifold<LeftValue, RightValue>(monad): LeftValue | RightValue

Unwraps either the left or the right value of the provided monad.

Type parameters

Name
LeftValue
RightValue

Parameters

NameType
monadEither<LeftValue, RightValue>

Returns

LeftValue | RightValue

bifold<Monad>(monad): Bifold<Monad>

Unwraps either the left or the right value of the provided monad.

Type parameters

NameType
Monadextends Either<any, any>

Parameters

NameType
monadMonad

Returns

Bifold<Monad>


bifoldMap

bifoldMap<LeftValue, RightValue, Value>(map): (monad: Either<LeftValue, RightValue>) => Value

Maps provided monad to a value, then returns it.

Type parameters

Name
LeftValue
RightValue
Value

Parameters

NameType
mapMap<LeftValue | RightValue, Value>

Returns

fn

▸ (monad): Value

Parameters
NameType
monadEither<LeftValue, RightValue>
Returns

Value

bifoldMap<LeftValue, RightValue, Value>(monad, map): Value

Maps provided monad to a value, then returns it.

Type parameters

Name
LeftValue
RightValue
Value

Parameters

NameType
monadEither<LeftValue, RightValue>
mapMap<LeftValue | RightValue, Value>

Returns

Value

bifoldMap<LeftValue, RightValue, Value>(mapLeft, mapRight): (monad: Either<LeftValue, RightValue>) => Value

Maps left and right values of the provided monad to a value, then returns it.

Type parameters

Name
LeftValue
RightValue
Value

Parameters

NameType
mapLeftMap<LeftValue, Value>
mapRightMap<RightValue, Value>

Returns

fn

▸ (monad): Value

Parameters
NameType
monadEither<LeftValue, RightValue>
Returns

Value

bifoldMap<LeftValue, RightValue, Value>(monad, mapLeft, mapRight): Value

Maps left and right values of the provided monad to a value, then returns it.

Type parameters

Name
LeftValue
RightValue
Value

Parameters

NameType
monadEither<LeftValue, RightValue>
mapLeftMap<LeftValue, Value>
mapRightMap<RightValue, Value>

Returns

Value


bifoldl

bifoldl<Monad>(monad): Bifoldl<Monad>

Returns the left value of the provided monad. If the monad is Right, returns undefined.

Type parameters

NameType
Monadextends Left<any>

Parameters

NameType
monadMonad

Returns

Bifoldl<Monad>

bifoldl<LeftValue>(monad): LeftValue | undefined

Returns the left value of the provided monad. If the monad is Right, returns undefined.

Type parameters

Name
LeftValue

Parameters

NameType
monadEither<LeftValue, any>

Returns

LeftValue | undefined


bifoldlMap

bifoldlMap<LeftValue, Value>(map): (monad: Either<LeftValue, any>) => Value | undefined

Maps provided monad's left value to a new value, then returns it or undefined.

Type parameters

Name
LeftValue
Value

Parameters

NameType
mapMap<LeftValue, Value>

Returns

fn

▸ (monad): Value | undefined

Parameters
NameType
monadEither<LeftValue, any>
Returns

Value | undefined

bifoldlMap<LeftValue, Value>(monad, map): Value | undefined

Maps provided monad's left value to a new value, then returns it or undefined.

Type parameters

Name
LeftValue
Value

Parameters

NameType
monadEither<LeftValue, any>
mapMap<LeftValue, Value>

Returns

Value | undefined

bifoldlMap<Monad, Value>(map): (monad: Monad) => Value

Maps provided monad's left value to a new value, then returns it or undefined.

Type parameters

NameType
Monadextends Left<any>
ValueValue

Parameters

NameType
mapMap<Bifoldl<Monad>, Value>

Returns

fn

▸ (monad): Value

Parameters
NameType
monadMonad
Returns

Value

bifoldlMap<Monad, Value>(monad, map): Value

Maps provided monad's left value to a new value, then returns it or undefined.

Type parameters

NameType
Monadextends Left<any>
ValueValue

Parameters

NameType
monadMonad
mapMap<Bifoldl<Monad>, Value>

Returns

Value


bifoldr

bifoldr<Monad>(monad): Bifoldr<Monad>

Returns the right value of the provided monad. If the monad is Left, returns undefined.

Type parameters

NameType
Monadextends Right<any>

Parameters

NameType
monadMonad

Returns

Bifoldr<Monad>

bifoldr<RightValue>(monad): RightValue | undefined

Returns the right value of the provided monad. If the monad is Left, returns undefined.

Type parameters

Name
RightValue

Parameters

NameType
monadEither<any, RightValue>

Returns

RightValue | undefined


bifoldrMap

bifoldrMap<RightValue, Value>(map): (monad: Either<any, RightValue>) => Value | undefined

Maps provided monad's right value to a new value, then returns it or undefined.

Type parameters

Name
RightValue
Value

Parameters

NameType
mapMap<RightValue, Value>

Returns

fn

▸ (monad): Value | undefined

Parameters
NameType
monadEither<any, RightValue>
Returns

Value | undefined

bifoldrMap<RightValue, Value>(monad, map): Value | undefined

Maps provided monad's right value to a new value, then returns it or undefined.

Type parameters

Name
RightValue
Value

Parameters

NameType
monadEither<any, RightValue>
mapMap<RightValue, Value>

Returns

Value | undefined

bifoldrMap<Monad, Value>(map): (monad: Monad) => Value

Maps provided monad's right value to a new value, then returns it or undefined.

Type parameters

NameType
Monadextends Right<any>
ValueValue

Parameters

NameType
mapMap<Bifoldr<Monad>, Value>

Returns

fn

▸ (monad): Value

Parameters
NameType
monadMonad
Returns

Value

bifoldrMap<Monad, Value>(monad, map): Value

Maps provided monad's right value to a new value, then returns it or undefined.

Type parameters

NameType
Monadextends Right<any>
ValueValue

Parameters

NameType
monadMonad
mapMap<Bifoldr<Monad>, Value>

Returns

Value


bimap

bimap<LeftValue, RightValue, NextLeftValue, NextRightValue>(mapLeft, mapRight): (monad: Either<LeftValue, RightValue>) => Either<NextLeftValue, NextRightValue>

Maps left and right values of the provided monad to a new Either monad.

Type parameters

Name
LeftValue
RightValue
NextLeftValue
NextRightValue

Parameters

NameType
mapLeftMap<LeftValue, NextLeftValue>
mapRightMap<RightValue, NextRightValue>

Returns

fn

▸ (monad): Either<NextLeftValue, NextRightValue>

Parameters
NameType
monadEither<LeftValue, RightValue>
Returns

Either<NextLeftValue, NextRightValue>

bimap<LeftValue, RightValue, NextLeftValue, NextRightValue>(monad, mapLeft, mapRight): Either<NextLeftValue, NextRightValue>

Maps left and right values of the provided monad to a new Either monad.

Type parameters

Name
LeftValue
RightValue
NextLeftValue
NextRightValue

Parameters

NameType
monadEither<LeftValue, RightValue>
mapLeftMap<LeftValue, NextLeftValue>
mapRightMap<RightValue, NextRightValue>

Returns

Either<NextLeftValue, NextRightValue>


bindr

bindr<LeftValue, RightValue, NextRightValue>(mapRight): (monad: Either<LeftValue, RightValue>) => Either<LeftValue, NextRightValue>

Maps right value to a new monad returning it.

Type parameters

Name
LeftValue
RightValue
NextRightValue

Parameters

NameType
mapRightMap<RightValue, Either<LeftValue, NextRightValue>>

Returns

fn

▸ (monad): Either<LeftValue, NextRightValue>

Parameters
NameType
monadEither<LeftValue, RightValue>
Returns

Either<LeftValue, NextRightValue>

bindr<LeftValue, RightValue, NextRightValue>(monad, mapRight): Either<LeftValue, NextRightValue>

Maps right value to a new monad returning it.

Type parameters

Name
LeftValue
RightValue
NextRightValue

Parameters

NameType
monadEither<LeftValue, RightValue>
mapRightMap<RightValue, Either<LeftValue, NextRightValue>>

Returns

Either<LeftValue, NextRightValue>


first

first<LeftValue, RightValue, NextLeftValue>(mapLeft): (monad: Either<LeftValue, RightValue>) => Either<NextLeftValue, RightValue>

Maps the left value of the provided monad to a new Either monad with the same right value.

Type parameters

Name
LeftValue
RightValue
NextLeftValue

Parameters

NameType
mapLeftMap<LeftValue, NextLeftValue>

Returns

fn

▸ (monad): Either<NextLeftValue, RightValue>

Parameters
NameType
monadEither<LeftValue, RightValue>
Returns

Either<NextLeftValue, RightValue>

first<LeftValue, RightValue, NextLeftValue>(monad, mapLeft): Either<NextLeftValue, RightValue>

Maps the left value of the provided monad to a new Either monad with the same right value.

Type parameters

Name
LeftValue
RightValue
NextLeftValue

Parameters

NameType
monadEither<LeftValue, RightValue>
mapLeftMap<LeftValue, NextLeftValue>

Returns

Either<NextLeftValue, RightValue>


isEither

isEither<LeftValue, RightValue>(value): value is Either<LeftValue, RightValue>

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

Type parameters

Name
LeftValue
RightValue

Parameters

NameType
valueany

Returns

value is Either<LeftValue, RightValue>


isLeft

isLeft<LeftValue>(value): value is Left<LeftValue>

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

Type parameters

Name
LeftValue

Parameters

NameType
valueany

Returns

value is Left<LeftValue>


isRight

isRight<RightValue>(value): value is Right<RightValue>

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

Type parameters

Name
RightValue

Parameters

NameType
valueany

Returns

value is Right<RightValue>


second

second<LeftValue, RightValue, NextRightValue>(mapRight): (monad: Either<LeftValue, RightValue>) => Either<LeftValue, NextRightValue>

Maps the right value of the provided monad to a new Either monad with the same left value.

Type parameters

Name
LeftValue
RightValue
NextRightValue

Parameters

NameType
mapRightMap<RightValue, NextRightValue>

Returns

fn

▸ (monad): Either<LeftValue, NextRightValue>

Parameters
NameType
monadEither<LeftValue, RightValue>
Returns

Either<LeftValue, NextRightValue>

second<LeftValue, RightValue, NextRightValue>(monad, mapRight): Either<LeftValue, NextRightValue>

Maps the right value of the provided monad to a new Either monad with the same left value.

Type parameters

Name
LeftValue
RightValue
NextRightValue

Parameters

NameType
monadEither<LeftValue, RightValue>
mapRightMap<RightValue, NextRightValue>

Returns

Either<LeftValue, NextRightValue>