[GHC] #4517: Add Data.Functor.Backwards to transformers

Ross Paterson ross at soi.city.ac.uk
Fri Dec 10 12:19:17 CET 2010

On Tue, Nov 23, 2010 at 11:40:40AM -0500, roconnor at theorem.ca wrote:
> Discussion so far.
> There are three aspects of functors that can be "reversed"
> 1. Foldable-Traversable
> 2. Applicative
> 3. Alternative-MonadPlus
> It appears at first glance that all three of these aspects are
> independent and thus we would need three different wrappers to
> implement the three separate functionality.  For example lists have
> all three aspects and one can imagine possibly reversing list
> instances independently in each of the aspects.

Ignoring 3 for the moment, there are basically two choices:

(1) the current design, with a single type constructor that reverses
the order of Applicative effects and also the order of Foldable and


(2) two type constructors, both with derived Functor instances:
  * one morally equivalent to reversing the arguments of all the data
    constructors: Foldable and Traversable process elements in the reverse
    order, but other instances (Applicative and Monad) are derived.
  * one with an Applicative instance that reverses the order of effects,
    but Foldable and Traversable are derived.  There wouldn't be a Monad
    instance, because it's not possible to define one that's compatible
    with the Applicative instance.

The second design seems slightly cleaner to me, though it's not a big deal.

More information about the Libraries mailing list