← Back

Source

identity

Monad1<URI> &
  Foldable2v1<URI> &
  Traversable2v1<URI> &
  Alt1<URI> &
  Comonad1<URI> &
  ChainRec1<URI>

Added in v1.0.0 (instance)

Identity

constructor(readonly value: A) {}

Added in v1.0.0 (data)

alt

(fx: Identity<A>): Identity<A>

Added in v1.0.0 (method)

ap

<B>(fab: Identity<(a: A) => B>): Identity<B>

Added in v1.0.0 (method)

ap_

<B, C>(this: Identity<(b: B) => C>, fb: Identity<B>): Identity<C>

Added in v1.0.0 (method)

Flipped version of ap

chain

<B>(f: (a: A) => Identity<B>): Identity<B>

Added in v1.0.0 (method)

extend

<B>(f: (ea: Identity<A>) => B): Identity<B>

Added in v1.0.0 (method)

extract

(): A

Added in v1.0.0 (method)

fold

<B>(f: (a: A) => B): B

Added in v1.0.0 (method)

inspect

(): string

Added in v1.0.0 (method)

map

<B>(f: (a: A) => B): Identity<B>

Added in v1.0.0 (method)

orElse

(fx: Lazy<Identity<A>>): Identity<A>

Added in v1.6.0 (method)

Lazy version of alt

Example

import { Identity } from 'fp-ts/lib/Identity'

const a = new Identity(1)
assert.deepEqual(a.orElse(() => new Identity(2)), a)

reduce

<B>(b: B, f: (b: B, a: A) => B): B

Added in v1.0.0 (method)

toString

(): string

Added in v1.0.0 (method)

getSetoid

<A>(setoid: Setoid<A>): Setoid<Identity<A>>

Added in v1.0.0 (function)