All Monads are Functors

Ross Paterson ross at soi.city.ac.uk
Sat Sep 30 10:46:10 EDT 2006


On Sat, Sep 30, 2006 at 12:41:42PM +0100, Conor McBride wrote:
> So, with this arrangement, quite a lot of library functionality is
> potentially affected (good!), especially if Traversable is also kicking
> around, allowing us
> 
>  crush :: (Monoid t, Traversable f) => (s -> t) -> f s -> t
> 
> (1) Which library functions should just be binned?
> (2) Which library functions should be retained but generalised (eg,
> working for Applicative rather than Monad, or any Traversable f rather
> than just [])? In particular, what happens to mapM?

For some possible answers, see

http://www.haskell.org/ghc/dist/current/docs/libraries/base/Data-Foldable.html
http://www.haskell.org/ghc/dist/current/docs/libraries/base/Data-Traversable.html

coming soon to all Haskell implementations.  For crush, there's

	foldMap :: (Foldable f, Monoid m) => (a -> m) -> f a -> m

Ashley's quite ambitious to push this refactoring of Monad for Haskell',
since there is limited experience with Applicative, and class system
changes that might help with fine-grained hierarchies are unlikely to
be available, but I wish him luck.

I've collected several such issues on the StandardClasses page.



More information about the Haskell-prime mailing list