Haskell Language Functor


Functor is the class of types f :: * -> * which can be covariantly mapped over. Mapping a function over a data structure applies the function to all the elements of the structure without changing the structure itself.


A Functor can be thought of as a container for some value, or a computation context. Examples are Maybe a or [a]. The Typeclassopedia article has a good write-up of the concepts behind Functors.

To be considered a real Functor, an instance has to respect the 2 following laws:


fmap id == id


fmap (f . g) = (fmap f) . (fmap g)