Classes implementing bind()
are expected to satisfy three monad laws: left
identity, right identity, and associativity.
Details
The Haskell monad laws can be translated into R as follows:
- Left identity:
pure(a) %>-% h
is equal toh(a)
.- Right identity:
m %>-% pure
is equal tom
.- Associativity:
(m %>-% g) %>-% h
is equal tom %>-% \(x) g(x) %>-% h
.
See also
Other implementation laws:
functor-laws