Skip to contents

Classes implementing fmap() are expected to satisfy two functor laws: preservation of identity and preservation of composition.

Arguments

m

A functor object.

f, g

Functions.

Details

The Haskell functor laws can be translated into R as follows:

Preservation of identity:

m %>>% identity is equal to m |> identity().

Preservation of composition:

m %>>% (f %.% g) is equal to m %>>% g %>>% f.

Where above %.% denotes function composition \(f, g) \(x) f(g(x)).

See also

Other implementation laws: monad-laws