Applicative and Functor
Ashley Yakeley
ashley at semantic.org
Mon Mar 6 15:36:01 EST 2006
Ross Paterson wrote:
>>The Prelude is to obvious place, since that's where both Functor and
>>(->) are introduced.
>
> Yes, but that would break compatibility with Haskell 98.
In that case, we should just create a new module.
> OK, one client but no instances.
Fair enough. I like the separation of functionality on principle, but
it's difficult to justify without instances.
I propose:
1. A new module Data.Functor, exporting Functor and all its instances
from the Prelude, as well as "instance Functor ((->) a)".
2. Making Functor a superclass of Applicative, and getting rid of <$>.
3. Making Functor and Foldable superclasses of Traversable, and getting
rid of fmapDefault and foldMapDefault.
You might also consider:
4. Adding a method to "class Traversable t" (with a default implementation):
toList :: t a -> [a]
5. Renaming pure as returnA and <*> as apA. Only it looks like your
Arrows stole returnA.
Also:
If Functor is a superclass of Traversable, is it better to have traverse
and mapM as the methods, or sequence and sequenceA?
What's your "instance Applicative []"? Does it use repeat and zapp, or
is it the "list of successes" (which would be compatible with "instance
Monad []")?
--
Ashley Yakeley, Seattle WA
WWED? http://www.cs.utexas.edu/users/EWD/
More information about the Libraries
mailing list