We know that any generic type F[_]
withmap
method, which complies to some laws, is a functor. For instance, List[_]
, Option
I don't know Scala, but in Haskell, the Functor
class is essential to defining Van Laarhoven-style lenses:
type Lens' s a = forall f . Functor f => (a -> f a) -> s -> f s
These lenses are typically defined for specifically-related types s
and a
, but it's essential to their utility that they work with an arbitrary functor.
Functor
is also important in its role as a superclass of Applicative
and of Traversable
. When working with these more powerful abstractions, it's often very useful to reach for the fmap
method.