minifunc

Monad

A monad is a type that represents a value that can be chained with different functions.

Initialization

import { Monad } from 'minifunc';

const monad = Monad.of(1);

Notes

API

Monad<T>

interface Monad<T> {
	of<U>(value: U): Monad<U>;
	map<U>(fn: (value: T) => U): Monad<U>;
	flatMap<U>(fn: (value: T) => Monad<U>): Monad<U>;
	get(): T; // Finishes the chain
}