control v0.1.0 Control.Functor protocol

Functors are things that can be mapped over, like lists, Maybes, trees, and such.

Using functors, we can generalize how Enum.map works for Enumerables on any data type, including Maybe. We can accomplish this by generalizing the action and implementing that action for the desired data types. This generalized action for functors is known as fmap.

Laws

All implementations of Control.Functor should obey the following implicit laws:

f |> fmap(id)      = id.(f)
f |> fmap(q <|> p) = f |> fmap(p) |> fmap (q)

where f is a functor, id is a function that returns its input, and p & q are functions.

Link to this section Summary

Functions

The mapping function

Link to this section Types

Link to this type t()
t() :: term()

Link to this section Functions

Link to this function fmap(functor, fun)
fmap(t(), (term() -> term())) :: t()

The mapping function.