[Haskell-cafe] Smarter do notation

Shachaf Ben-Kiki shachaf at gmail.com
Sun Sep 4 09:11:27 CEST 2011


On Sat, Sep 3, 2011 at 19:34, Daniel Peebles <pumpkingod at gmail.com> wrote:
...
> Of course, the fact that the return method is explicitly mentioned in my
> example suggests that unless we do some real voodoo, Applicative would have
> to be a superclass of Monad for this to make sense. But with the new default
> superclass instances people are talking about in GHC, that doesn't seem too
> unlikely in the near future.
...

One way to avoid explicitly mentioning return would be to use monad
comprehension syntax, which uses return implicitly, instead of do
notation. This also has the advantage of being "new" in GHC 7.2,
rather than officially being part of Haskell 98/2010, and therefore
being more amenable to various extensions (e.g. there are already
extensions that use MonadPlus/MonadZip/MonadGroup). Applicative would
probably still have to be a superclass of Monad, but the translation
of this syntax is simpler.

    Shachaf



More information about the Haskell-Cafe mailing list