In functional programming, a "functor" is a function on types F : Type u → Type v
equipped with an operator called map
or <$>
such that if f : α → β
then
map f : F α → F β
, so f <$> x : F β
if x : F α
. This corresponds to the
category-theory notion of functor in
the special case where the category is the category of types and functions
between them, except that this class supplies only the operations and not the
laws (see LawfulFunctor
).
Instance Constructor
Functor.mk.{u, v}
Methods
map : {α β : Type u} → (α → β) → f α → f β
If f : α → β
and x : F α
then f <$> x : F β
.
mapConst : {α β : Type u} → α → f β → f α
The special case const a <$> x
, which can sometimes be implemented more
efficiently.