An
HFunctor can be thought of a unary "functor transformer" ---
a basic functor combinator. It takes a functor as input and returns a
functor as output.
It "enhances" a functor with extra structure (sort of like how a monad
transformer enhances a
Monad with extra structure).
As a uniform inteface, we can "swap the underlying functor" (also
sometimes called "hoisting"). This is what
hmap does: it lets
us swap out the
f in a
t f for a
t g.
For example, the free monad
Free takes a
Functor and
returns a new
Functor. In the process, it provides a monadic
structure over
f.
hmap lets us turn a
Free
f into a
Free g: a monad built over
f
can be turned into a monad built over
g.
For the ability to move in and out of the enhanced functor, see
Inject and
Interpret.
This class is similar to
MFunctor from
Control.Monad.Morph, but instances must work without a
Monad constraint.
This class is also found in the
hschema library with the same
name.