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

Identity

Extends:

Monad → Identity

Indirect Implements:

Class Identity - wraps underlying value into the monadic value and compute results from a monadic value.

Constructor Summary

Public Constructor
public

constructor(v: any)

Creates an instance of class Identity.

Member Summary

Public Members
public

The instance of ErrorM.

public

v: any

Keeps underlying value of a monad.

Method Summary

Public Methods
public

bind(f: MF<T, U>, v: any): Pr<U> | Error

Chains the operations on a monadic value.

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(v: any) source

Creates an instance of class Identity.

Params:

NameTypeAttributeDescription
v any
  • optional

The initial state of app.

Public Members

public err: ErrorM source

The instance of ErrorM.

public v: any source

Keeps underlying value of a monad.

Public Methods

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

Chains the operations on a monadic value.

Override:

Monad#bind

Params:

NameTypeAttributeDescription
f MF<T, U>

transformation function for the monad.

v any
  • optional
  • default: this.v

underlying value for the monad, it can be null.

Return:

Pr<U> | Error