Monad
(Note - don’t use this, use cats)
Simple implementation of a Monad
type class. Subclasses only need to override apply
and flatMap
, but they should override map
, join
, joinWith
, and sequence
if there are better implementations.
Laws Monad
instances must follow:
identities:
flatMap(apply(x))(fn) == fn(x)
flatMap(m)(apply _) == m
associativity on flatMap
(you can either flatMap
f
first, or f
to g
):
flatMap(flatMap(m)(f))(g) == flatMap(m) { x => flatMap(f(x))(g) }
Documentation Help
We’d love your help fleshing out this documentation! You can edit this page in your browser by clicking this link. These links might be helpful: