import { type Monad } from "https://deno.land/x/fun@v2.0.0-alpha.6/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:
- Left identity: chain(f)(of(a)) === f(a)
- Right identity: chain(of)(ua) === ua
The original type came from static-land
Type Parameters
U extends Kind