PROPOSAL: classes for traversals

Ross Paterson ross at soi.city.ac.uk
Mon Nov 21 05:09:26 EST 2005


On Sat, Nov 19, 2005 at 05:51:44PM +0300, Bulat Ziganshin wrote:
> -- If @f@ is also a 'Functor', define @('<$>') = 'fmap'@.
> -- If it is also a 'Monad', define @'pure' = 'return'@ and @('<*>') = 'ap'@.
> 
> why you don't just define:
> 
> instance Monad m => Applicative m where
>         pure = return
>         (<*>) = ap

Because that instance would overlap with all others.  As it is, these
classes are Haskell 98.  Better language support for superclasses would
be useful here, but is unavailable right now.

> RP> They are proposed for the base package, and would replace FunctorM.
> 
> it is a beatiful contribution. but it doesn't work without definitions
> for All, Any and so on :)

I'm not sure I understand this one.  These types are defined in
Data.Monoid in CVS, and coming soon to a Haskell implementation near you.



More information about the Libraries mailing list