Functors, applicative functors, monads

This diagram demonstrates the relationship between certain Functor, Applicative and Monad operators.

See the Typeclassopedia for details.

Functors, applicative functors, monads

The (→) a instance

This diagram demonstrates the properties of certain Functor, Applicative and Monad operators when using the (→) a instance.

(It’s interesting to note how the types, when specialized to the (→) a instance, dictate the only correct behavior for each one.)

(<$>) f g x = f (g x)
(<*>) f h x = f x (h x)
(=<<) f g x = f (g x) x
liftA2 f g h x ≡ f (g x) (h x)
join f x ≡ f x x

Although completely unrelated to functors, a visualization of on might be appropriate here, since it has some conceptual similarity to the combinators above. (Well, it could be implemented in terms of them as (f `on` g) x y = liftA2 f ($x) ($y) g).

(f `on` g) x y = f (g x) (g y)

(Inspired by mauke’s diagram.)

(Source code for the diagram.)