class Functor f where fmap :: (a -> b) -> f a -> f b
f
transforms types to types, and fmap
brings functions along. If f
represents a container like []
, then fmap
applies functions "inside" the container.
λ> fmap (1+) $ Just 5 Just 6
Rules for fmap
(same as monoid transformation rules!):
fmap id ←→ id fmap (g . h) ←→ (fmap g) . (fmap h)