functor-laws | R Documentation |
Classes implementing fmap()
are expected to satisfy two functor laws:
preservation of identity and preservation of composition.
m |
A functor object. |
f , g |
Functions. |
The Haskell functor laws can be translated into R as follows:
m %>>% identity
is equal to m |> identity()
.
m %>>% (f %.% g)
is equal to m %>>% g %>>% f
.
Where above %.%
denotes function composition \(f, g) \(x) f(g(x))
.
https://wiki.haskell.org/Functor#Functor_Laws
Other implementation laws:
monad-laws
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.