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.

See also

Other implementation laws: monad-laws