To use deriving Functor
you must enable the DeriveFunctor
language pragma and apply it to a polymorphic type which has a covariant final type variable—in other words, a type which admits a valid Functor
instance. It’ll then derive the “obvious” Functor
instance.
There’s been some concern in the past that the derived instance is not as efficient as a hand coded one is, though I cannot seem to find that material.
The algorithm itself was, as far as I could find, first proposed by Twan Van Laarhoven in 2007 and makes heavy use of Generic Haskell programming.