do-and-if-then-else modification

Malcolm Wallace Malcolm.Wallace at
Mon Feb 19 06:16:03 EST 2007

isaac jones <ijones at> wrote:

> Iavor and I just made the trivial modification for DoAndIfThenElse
> Any comments on this modification?  How do people feel about the
> suggestion that we do it for case statements as well?

I'm happy to allow the change for if-then-else.  The need for extra
indentation there has annoyed me a few times.

However, I have never come across the case-of expression variation in
practice.  Indeed, the wiki page is not very clear on what exactly the
problem is.  For instance, until a few minutes ago, the given example
was merely:

    case whatever
       blah  -> bluh
       blah' -> bluh'

However, that is already perfectly legal Haskell'98.  I just changed the
example to read

    do case whatever
          blah  -> bluh
          blah' -> bluh'

since that is what I thought was perhaps intended.  And indeed that is
rejected by a H'98 parser.  But it seems a bit of an unlikely coding
style.  And it now occurs to me that perhaps something different was
intended.  The following is legal H'98:

    case whatever of
    Cons -> bluh
    Nil  -> foo

But stick it in a do block and it ceases to be accepted:

    do case whatever of
       Cons -> bluh
       Nil  -> foo

Now for myself, I tend to strictly indent the alternatives in a case
expression, but I can see that if you prefer non-indented alternatives,
then the latter would indeed be annoying.


More information about the Haskell-prime mailing list