FW: H98 Report: expression syntax glitch

Simon Peyton-Jones simonpj@microsoft.com
Tue, 12 Mar 2002 05:00:36 -0800

In response to my recent message (below), Ross asks:

"Are you rejecting the fix I suggested:

	Add a side condition to the grammar in 3.13: the guard must not
	end with a type signature (because the following -> looks like
	part of the type)."

Indeed, this would be possible.  It would reject programs like
	f x =3D case x of { (a,b) | b :: Bool -> a }
which are in principle reasonable, but are really hard to parse.
Indeed, GHC, Hugs, and nhc all reject it.

I suppose that the term "ends with" is a bit imprecise, too.  Presumably
this would be OK
	f x =3D case x of { (a,b) | (b :: Bool) -> a }

Still, Ross's suggestion is pragmatic: if all the impls find this corner
of the language too hard to parse, then some guidance about what=20
not to write would be a good plan.

As usual, this is not a big deal: it's a dark corner that few will trip
over.  But it is my joyful task (aided by many others) to try to=20
illuminate the darkness, so I invite your opinions about which
fix (the one below, or Ross's) is better.


-----Original Message-----
From: Ross Paterson [mailto:ross@soi.city.ac.uk]=20
Sent: 11 March 2002 17:59
To: Simon Peyton-Jones
Subject: Re: H98 Report: expression syntax glitch


> Ross points out that this is really hard to parse:
> | 	case x of y | ($ True) $ \ z -> z :: Bool -> Bool -> y
> because the parser doesn't know when to stop eating the type and treat

> the arrow as the case-alternative arrow.

> But in neither case can I see a cure that is better than the
> disease.  Remember, large-scale fixes are out of court.

An easier case than Carl's, I think.