[Haskell-cafe] Re: monad subexpressions

Chris Smith cdsmith at twu.net
Fri Aug 3 14:36:30 EDT 2007


Claus Reinke <claus.reinke at talk21.com> wrote:
> to illustrate why some of us are concerned about this extension,
> a few examples might help.

Claus, I've been saving your message in order to respond to it when I 
have the time to look over it in detail.  I don't think there will be 
forthcoming answers from me, though.  Ultimately, it may just have to 
come down to implementing the extension, making it available as an 
extension to GHC and perhaps other Haskell compilers, and then learning 
from people's experience.

If there is a really good syntax that avoids the need for language 
changes, that would be great.  If there's one that's clearly good enough 
and pops up before I finish this, then I may even abort the work.  As it 
stands, though, I'm just not sure how to evaluate ideas without language 
changes against an alternative that doesn't exist.  This is especially 
true when we're talking about non-quantifiable ideas like convenience, 
readability, and intuitiveness.

As such, I'm happy to pursue the language change route, so that we'll 
have a real implementation and a fully developed idea, instead of a 
theory to discuss.  I suspect it will then be more productive to talk 
about the options, such as whether the language change is really needed 
or beneficial.


Neil and I just discussed some of the semantic issues you raise here in 
another subthread.  Some of them are not quite as intuitive as I'd like, 
but the meaning is at least well-defined.  As for this thread, yes I 
agree with Simon that it's necessary to choose your "option c" and tie 
any new syntax rather tightly to the 'do' keyword; anything else 
involves becoming a mind-reader.

> if (c), then the following are no longer equivalent
> 
>     1. return ...
>     2. do return ...

Yes, that is true.

> if you weren't, here's
> a quick question: we've already seen the left- and right-identity
> laws in danger, so what about associativity?
> 
>     do { do { a; b}; c } 
> 
> is still the same as
>             
>     do { a; do { b; c } }
> 
> yes? no? perhaps? sometimes? how long did it take you?

I'm not entirely sure I understand the point here.  The monad laws are 
defined in terms of >>= and return.  They have never had anything to do 
with do, let, or <-.  All of the monad laws still hold.

-- 
Chris Smith



More information about the Haskell-Cafe mailing list