2014 Applicative => Monad proposal

Edward Kmett ekmett at gmail.com
Thu May 23 22:44:28 CEST 2013


+1 on doing this. Period.

That said, there are a couple of ways that this proposal could be
pragmatically improved.

The DefaultSignatures extension could be used to permit (GHC) users to
avoid having to define definitions for the Functor and Applicative
combinators (for simple monads, anyways.)

class Functor f where
   fmap :: (a -> b) -> f a -> f b
#ifdef __DEFAULT_SIGNATURES__
   default fmap :: Monad f => (a -> b) -> f a -> f b
   fmap = liftM
#endif

class Functor f => Applicative f where
   pure :: a -> f a
#ifdef __DEFAULT_SIGNATURES__
   default pure :: Monad f => a -> f a
   pure = return
#endif

   (<*>) :: f (a -> b) -> f a -> f b
#ifdef __DEFAULT_SIGNATURES__
   default (<*>) :: Monad f => f (a -> b) -> f a -> f b
   (<*>) = ap
#endif

This would have the side-effect of replacing the return = pure definition
though.

I offer it as a potential refinement on its own, that comes with its own
benefits and limitations, but I want to be clear, my approval for this
proposal stands regardless of this detail!

-Edward



On Thu, May 23, 2013 at 3:39 PM, David Luposchainsky <
dluposchainsky at googlemail.com> wrote:

> Hello libraries,
>
> it's on! Time to tackle the Applicative-Monad issue, hopefully once and
> for all. Over the last couple of weeks I've looked through previous
> proposals, asked #haskell about their opinions, and compiled it all into
> one file that sums up what I made of that. It's a bit long for an email
> and uses markdown, so I'll just provide links at the end of this mail
> instead of pasting it in here. In there, the whole thing and how to
> approach it is explained in more detail. Here's an abstract of what it
> the proposal consists of:
>
>
> - Don't break compatibility
> - Apply it gently
>
> - Applicative m => Monad m
> - Applicative into Prelude (and therefore into the Report)
> - (Alternative m, Monad m) => MonadPlus m
> - Promote `join` into the Monad typeclass
>
>
> Let's make this happen! I'm going to give a ballpark discussion period
> of four weeks, but since I can imagine this discussion could become
> quite complex we shouldn't take it too serious. I'll summarize what's
> been going on periodically though.
>
> David
>
>
>
> Links:
>
> The proposal text on Github (link fixed, sorry for the deadlink yesterday):
> https://github.com/quchen/articles/blob/master/applicative_monad.md
> (This file is subject to changes, depending on how this discussion goes.
> I'll try to make it reflect the current consensus.)
>
> And just in case Github silentbans me again for submitting too many
> edits to my Gist (grrr), here's a copy of the file on HPaste as backup:
> http://hpaste.org/88423
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://www.haskell.org/mailman/listinfo/libraries
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20130523/c8fcb18f/attachment.htm>


More information about the Libraries mailing list