Home Reference Source Repository
import {Either} from 'monad-ts/src/either.js'
public class | source

Either

Extends:

Monad → Either

Indirect Implements:

Class Either - represents computation with two possibilities.

Constructor Summary

Public Constructor
public

constructor(r: function(v: any), l: function(v: any))

Creates an instance of class Either.

Method Summary

Public Methods
public

bind(f: D<T>, v: any): boolean | Pr<any> | Error

Binds controller function and underlying value to the monad.

public

left(v: T): Pr

Extract result of left(v) computation.

public

right(v: T): Pr

Extract result of right(v) computation.

Inherited Summary

From class Monad
public abstract

bind(f: MF<T, U>|D<T>, v: *): Promise<U> | Pr<U> | Error | boolean | void

Binds transformation function and underlying value to the monad.

protected

fail(e: Error | string): Error

Takes Error or string return Error.

protected

just(f: function(v: T), v: T): Pr<U>

Produces result after execution f(v).

Public Constructors

public constructor(r: function(v: any), l: function(v: any)) source

Creates an instance of class Either.

Params:

NameTypeAttributeDescription
r function(v: any)

right function.

l function(v: any)

left function.

Public Methods

public bind(f: D<T>, v: any): boolean | Pr<any> | Error source

Binds controller function and underlying value to the monad.

Override:

Monad#bind

Params:

NameTypeAttributeDescription
f D<T>

controller function, after execution f(v) produce true (execute right func-n) or false (execute left func-n).

v any

underlying value for the monad.

Return:

boolean | Pr<any> | Error

public left(v: T): Pr source

Extract result of left(v) computation.

Params:

NameTypeAttributeDescription
v T

underlying value.

Return:

Pr

public right(v: T): Pr source

Extract result of right(v) computation.

Params:

NameTypeAttributeDescription
v T

underlying value.

Return:

Pr