Hi Simon,

You asked for comments, so here we go!

In my opinion, it is a mistake to insist on strictly increasing indentation
for nested layout.  I didn't notice this change in the Haskell 98 (which is
why Hugs 98 doesn't follow it!) because the posted list of changes for
Haskell 98 said only that the specification had been made more precise.
I had not realized that the original specification was ambiguous (although
that doesn't really surprise me :-) or that a decision had been made to
resolve it (unfortunately for Hugs users, in favor of GHC's interpretation
rather than Hugs' :-).

But the real problem, in my opinion, is in allowing empty where clauses,
which seems like a pretty dubious feature, and a redundant one also; if
you want it to be empty, don't write the "where" either!

You've already described some of the positive features of the Hugs
interpretation, and I do take your point that it has some downsides
too:

| The disadvantages include
| 
|       - leaving a dangling 'where' on a top-level declaration would 
|         eat up all the following declarations.  The current behaviour
|         handles this case nicely.
| 
|       - it becomes harder to write empty where clauses with layout.

For the first point, I suppose the real issue is concerned with the
error diagnostic that any given Haskell implementation might give
in this situation.  I would think it very unlikely that a dangling
where would not trigger an error at some point in the code, but that
error may not give a good pointer to the true origin of the problem.
That's an untested hypothesis, of course, and things may work better
in practice.

As you might guess from my comments about the dubious nature of empty
wheres, the second point doesn't concern me here!

| The 'case' problem
| ------------------
| 
| It seems reasonable to want to write
| 
|       case e1 of (p,q) ->
|       case e2 of (r,s) ->
|       ...
| 
| but this is rejected by Haskell 98 (and all previous versions).  
| Most of the
| time we end up writing
| 
|       case e1 of { (p,q) ->
|       case e2 of { (r,s) ->
|       ...
|       }}
| 
| but this is annoying because you have to adjust the number of 
| braces at the end of the expression when you add or remove a case.
| ...
| I don't know of any fix, but I just mention this here in case 
| anyone has any ideas.

Something like the following can be used in Hugs 98:

  f x = case x of
        (a,b) -> case a of
        (c,d) -> case b of
        (e,f) -> [c,d,e,f]

Of course, this will break if we change Hugs to insist on strictly
increasing indentation :-(

All the best,
Mark



Reply via email to