Options
All
  • Public
  • Public/Protected
  • All
Menu

The Chain type-class is a lightweight Monad.

It exposes chain, which allows to have a value in a context (F<A>) and then feed that into a function that takes a normal value and returns a value in a context (A => F<B>).

One motivation for separating this out from Monad is that there are situations where we can implement chain but not of. For example, we can implement map or chain that transforms the values of a Map<K, ?> type, but we can't implement of (because we wouldn't know what key to use when instantiating the new Map).

In addition to Apply's laws, Chain instances must obey these laws:

  1. Associativity: F.chain(g, F.chain(f, fa)) <-> F.chain(x => F.chain(g, f(x)), fa)
  2. Apply's ap can be derived: (ff, fa) => F.chain(f => F.map(f, fa), ff)

Equivalent with the Chain type-class in the static-land specification.

Type parameters

  • F

Hierarchy

Index

Methods

Methods

ap

  • ap<A, B>(ff: HK<F, function>, fa: HK<F, A>): HK<F, B>
  • Type parameters

    • A

    • B

    Parameters

    • ff: HK<F, function>
    • fa: HK<F, A>

    Returns HK<F, B>

chain

  • chain<A, B>(f: function, fa: HK<F, A>): HK<F, B>
  • Type parameters

    • A

    • B

    Parameters

    • f: function
        • (a: A): HK<F, B>
        • Parameters

          • a: A

          Returns HK<F, B>

    • fa: HK<F, A>

    Returns HK<F, B>

map

  • map<A, B>(f: function, fa: HK<F, A>): HK<F, B>
  • Type parameters

    • A

    • B

    Parameters

    • f: function
        • (a: A): B
        • Parameters

          • a: A

          Returns B

    • fa: HK<F, A>

    Returns HK<F, B>

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc