Skip to main content
Module

x/fun/monad.ts>Monad

A collection of algebraic data types, lenses, and schemables based on a light weight higher kinded type implementation. Written for deno.
Go to Latest
interface Monad
implements Applicative<U>, Chain<U>, TypeClass<U>
import { type Monad } from "https://deno.land/x/fun@v.2.0.0-alpha.11/monad.ts";

A Monad is an algebra with a notion of join(aka flatten or flat) for a given algebraic data type T. A Monad must also extend Functor, Apply, Applicative, and Chain. This means a Monad has the following methods: of, ap, map, join, and chain. An intuition for Monad can be found by thinking about how Promise.then handles functions that return a new Promise.

An instance of a Monad must obey the following laws:

  1. Left identity: chain(f)(of(a)) === f(a)
  2. Right identity: chain(of)(ua) === ua

The original type came from static-land

Properties

readonly
join: <A, B = never, C = never, D = unknown, E = unknown, J = never, K = never>(tta: $<U, [$<U, [A, B, C], [D], [E]>, J, K], [D], [E]>) => $<U, [A, B | J, C | K], [D], [E]>