Arrows that are also Functors

Edward Kmett ekmett at
Tue Apr 19 18:32:47 CEST 2011

On Tue, Apr 19, 2011 at 11:29 AM, Henning Thielemann <
lemming at> wrote:

> Is it common to make a type an instance of both Arrow and Functor type
> class? If a type is both instance of Arrow and Functor, would you expect
> that fmap = (^<<) ? If yes, how about adding this as expected law to the
> Control.Arrow documentation?

For any instance of Functor that is also an Arrow this must hold already
given existing laws.

One (particularly obvious) arrow law is that

arr id = id

This law states the fact that arr is the Functor from the category of
Haskell types to your arrow category.

Given that:

id ^<< g = arr id <<< g = g . arr id = g . id = g = id g

we can see (^<<) id = id is satisfied. The "second Functor law" comes for
free given (^<<) id = id, and the free theorem for (^<<), so (^<<) is
admissable as a definition for fmap.

Finally, valid Functor instances for a given type are unique.

This also follows from the free theorem for fmap and the side condition that
fmap id = id and has been worked through here on the cafe before. I believe
it was done most recently by Russell O'Connor.

So fmap = (^<<) must hold for any type that is both a valid instance of
Arrow and Functor.

The free theorem for fmap does all your work for you and no new laws need to
be placed on the books.


> Same question for Applicative functors and liftA2 (,) = (&&&). (Btw.
> Control.Arrow haddock documentation does not mention any Arrow law so far.)
> _______________________________________________
> Libraries mailing list
> Libraries at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Libraries mailing list