Applicative and Functor

Ross Paterson ross at soi.city.ac.uk
Mon Mar 6 04:11:38 EST 2006


On Sun, Mar 05, 2006 at 09:53:02PM -0800, Ashley Yakeley wrote:
> In article <20060305233414.GA8685 at soi.city.ac.uk>,
>  Ross Paterson <ross at soi.city.ac.uk> wrote:
> > so I would also need
> > 
> > 	instance Functor ((->) a)
> > 
> > but where should it go?  (The same instance occurs in
> > Control.Monad.Reader, but that could be removed.)
> 
> The Prelude is to obvious place, since that's where both Functor and 
> (->) are introduced.

Yes, but that would break compatibility with Haskell 98.

> > > There may also be a case for a class with ap (<*>) but not return 
> > > (pure), which might better be called "Applicative".
> > 
> > Do you have both instances and clients for this interface?
> 
> Well, no, but ap gives you (>>) (I'd forgotten this earlier):

OK, one client but no instances.

> > And can an associativity law even be stated?

On second thought, yes it can:

	fmap (.) u <*> v <*> w = u <*> (v <*> w)

> Traversable looks like my ExtractableFunctor? 
> <http://hbase.sourceforge.net/haddock/Org.Org.Semantic.HBase.Category.Ext
> ractableFunctor.html>

Yes it does, and also Meertens's "pullable functors" (though the
higher-order version is often more efficient, especially for non-regular
types).



More information about the Libraries mailing list