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
Name | Type |
---|---|
Monad | extends 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
Name | Type |
---|---|
Monad | extends 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
Name | Type |
---|---|
Monad | extends Either <any , any > |
First
Ƭ First<Monad
>: Monad
extends Left
<infer LeftValue> ? LeftValue
: Monad
extends Either
<infer LeftValue, any
> ? LeftValue
: never
Type parameters
Name | Type |
---|---|
Monad | extends Either <any , any > |
Second
Ƭ Second<Monad
>: Monad
extends Right
<infer RightValue> ? RightValue
: Monad
extends Either
<any
, infer RightValue> ? RightValue
: never
Type parameters
Name | Type |
---|---|
Monad | extends 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
Name | Type |
---|---|
monad | Either <LeftValue , RightValue > |
Returns
LeftValue
| RightValue
▸ bifold<Monad
>(monad
): Bifold
<Monad
>
Unwraps either the left or the right value of the provided monad
.
Type parameters
Name | Type |
---|---|
Monad | extends Either <any , any > |
Parameters
Name | Type |
---|---|
monad | Monad |
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
Name | Type |
---|---|
map | Map <LeftValue | RightValue , Value > |
Returns
fn
▸ (monad
): Value
Parameters
Name | Type |
---|---|
monad | Either <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
Name | Type |
---|---|
monad | Either <LeftValue , RightValue > |
map | Map <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
Name | Type |
---|---|
mapLeft | Map <LeftValue , Value > |
mapRight | Map <RightValue , Value > |
Returns
fn
▸ (monad
): Value
Parameters
Name | Type |
---|---|
monad | Either <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
Name | Type |
---|---|
monad | Either <LeftValue , RightValue > |
mapLeft | Map <LeftValue , Value > |
mapRight | Map <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
Name | Type |
---|---|
Monad | extends Left <any > |
Parameters
Name | Type |
---|---|
monad | Monad |
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
Name | Type |
---|---|
monad | Either <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
Name | Type |
---|---|
map | Map <LeftValue , Value > |
Returns
fn
▸ (monad
): Value
| undefined
Parameters
Name | Type |
---|---|
monad | Either <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
Name | Type |
---|---|
monad | Either <LeftValue , any > |
map | Map <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
Name | Type |
---|---|
Monad | extends Left <any > |
Value | Value |
Parameters
Name | Type |
---|---|
map | Map <Bifoldl <Monad >, Value > |
Returns
fn
▸ (monad
): Value
Parameters
Name | Type |
---|---|
monad | Monad |
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
Name | Type |
---|---|
Monad | extends Left <any > |
Value | Value |
Parameters
Name | Type |
---|---|
monad | Monad |
map | Map <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
Name | Type |
---|---|
Monad | extends Right <any > |
Parameters
Name | Type |
---|---|
monad | Monad |
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
Name | Type |
---|---|
monad | Either <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
Name | Type |
---|---|
map | Map <RightValue , Value > |
Returns
fn
▸ (monad
): Value
| undefined
Parameters
Name | Type |
---|---|
monad | Either <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
Name | Type |
---|---|
monad | Either <any , RightValue > |
map | Map <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
Name | Type |
---|---|
Monad | extends Right <any > |
Value | Value |
Parameters
Name | Type |
---|---|
map | Map <Bifoldr <Monad >, Value > |
Returns
fn
▸ (monad
): Value
Parameters
Name | Type |
---|---|
monad | Monad |
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
Name | Type |
---|---|
Monad | extends Right <any > |
Value | Value |
Parameters
Name | Type |
---|---|
monad | Monad |
map | Map <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
Name | Type |
---|---|
mapLeft | Map <LeftValue , NextLeftValue > |
mapRight | Map <RightValue , NextRightValue > |
Returns
fn
▸ (monad
): Either
<NextLeftValue
, NextRightValue
>
Parameters
Name | Type |
---|---|
monad | Either <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
Name | Type |
---|---|
monad | Either <LeftValue , RightValue > |
mapLeft | Map <LeftValue , NextLeftValue > |
mapRight | Map <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
Name | Type |
---|---|
mapRight | Map <RightValue , Either <LeftValue , NextRightValue >> |
Returns
fn
▸ (monad
): Either
<LeftValue
, NextRightValue
>
Parameters
Name | Type |
---|---|
monad | Either <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
Name | Type |
---|---|
monad | Either <LeftValue , RightValue > |
mapRight | Map <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
Name | Type |
---|---|
mapLeft | Map <LeftValue , NextLeftValue > |
Returns
fn
▸ (monad
): Either
<NextLeftValue
, RightValue
>
Parameters
Name | Type |
---|---|
monad | Either <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
Name | Type |
---|---|
monad | Either <LeftValue , RightValue > |
mapLeft | Map <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
Name | Type |
---|---|
value | any |
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
Name | Type |
---|---|
value | any |
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
Name | Type |
---|---|
value | any |
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
Name | Type |
---|---|
mapRight | Map <RightValue , NextRightValue > |
Returns
fn
▸ (monad
): Either
<LeftValue
, NextRightValue
>
Parameters
Name | Type |
---|---|
monad | Either <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
Name | Type |
---|---|
monad | Either <LeftValue , RightValue > |
mapRight | Map <RightValue , NextRightValue > |
Returns
Either
<LeftValue
, NextRightValue
>