do-and-if-then-else modification

Iavor and I just made the trivial modification for DoAndIfThenElse syntax as described here: http://hackage.haskell.org/trac/haskell-prime/wiki/DoAndIfThenElse You can see the change here: http://darcs.haskell.org/haskell-prime-report/report/haskell-report-html/exp... (Is there anything else that needs to change?) As always, we provide a quick view of the status of Haskell' here: http://hackage.haskell.org/trac/haskell-prime/wiki/Status%27 Any comments on this modification? How do people feel about the suggestion that we do it for case statements as well? peace, isaac

isaac jones wrote:
Iavor and I just made the trivial modification for DoAndIfThenElse syntax as described here: http://hackage.haskell.org/trac/haskell-prime/wiki/DoAndIfThenElse
You can see the change here:
http://darcs.haskell.org/haskell-prime-report/report/haskell-report-html/exp...
(Is there anything else that needs to change?)
"Section 3.6 Conditionals" would have to be changed accordingly. It still says "exp -> if exp1 then exp2 else exp3". Ben

Hello,
On 2/18/07, Benjamin Franksen
"Section 3.6 Conditionals" would have to be changed accordingly. It still says "exp -> if exp1 then exp2 else exp3". Thanks! I fixed this too.
Just for the record, I don't think that this change is particularly useful at all. We made the change because it is on the "definitely in" list accepted by the Haskell' committee and it seemed quite easy to do. -Iavor

isaac jones
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 of blah -> bluh blah' -> bluh' However, that is already perfectly legal Haskell'98. I just changed the example to read do case whatever of 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. Regards, Malcolm

On Mon, Feb 19, 2007 at 11:16:03AM +0000, Malcolm Wallace wrote:
isaac jones
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.
The semicolon before the "else" is the most useful. Adding another before the "then" has less motivation.
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.
The argument regarding "case" is that if you add a semicolon before "then", it would be consistent to also add one before "of".

Ross Paterson
The semicolon before the "else" is the most useful. Adding another before the "then" has less motivation.
do if foo then bar else baz seems just as likely to occur as do if foo then bar else baz particularly if the condition "foo" is large, and/or indentation is already running a long distance to the right.
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.
The argument regarding "case" is that if you add a semicolon before "then", it would be consistent to also add one before "of".
If the only argument is consistency, then surely the same applies to the "in" in a let expression. But of course this would correct a problem that never occurs in practice, because in a do-block one uses plain let, not let-in. So what evidence is there that case-of is a problem in practice? Regards, Malcolm

On 2/19/07, Ross Paterson
On Mon, Feb 19, 2007 at 11:16:03AM +0000, Malcolm Wallace wrote:
isaac jones
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.
The semicolon before the "else" is the most useful. Adding another before the "then" has less motivation.
I think it is a bad idea to make the non-layout syntax more complicated and less readable, just so that, indirectly, the layout syntax can be improved. Improvements to the layout mechanism should be localized to the section of the report describing layout, and such improvements shouldn't do anything to harm the non-layout syntax. In particular, why you don't just say that "else" and "of" act like ";" during layout? do { q <- if x ; then y ; else z ; return q } - Brian

On Mon, Feb 19, 2007 at 11:16:03AM +0000, Malcolm Wallace wrote:
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
No, that's a separate issue: NondecreasingIndentation.
participants (6)
-
Benjamin Franksen
-
Brian Smith
-
Iavor Diatchki
-
isaac jones
-
Malcolm Wallace
-
Ross Paterson