Haskell 98 Report possible errors, part one

Simon Marlow simonmar@microsoft.com
Mon, 23 Jul 2001 10:31:45 +0100


> 3. A precedence table says that case (rightwards) has higher=20
> precedence
> than operators and right associativity. If it's meaningful to talk
> about precedence of such syntactic constructs as case at all,=20
> it should
> probably be told to have a lower precedence, so "case x+1 of ..."
> is valid as "case (x+1) of ...". At least I don't see a difference
> between "case" (rightwards) and "if" (rightwards). I'm not sure if
> it makes sense to explain parsing of "case" in terms of precedence.

Interesting.  The table seems to say that case(rightwards) has a higher
precedence than infix operators, so that eg.

	case x of p -> x + y

would parse as

	(case x of p -> x) + y

which is in conflict with the longest parse rule.  I have no idea why
case(rightwards) is given a different precedence, and the inclusion of
'case alternative' in the list is confusing.

> 4.3.1. "A class declaration with no where part [...]
> The instance declaration must be given explicitly with no where part."
> Actually the where part may be present but empty, with the=20
> same meaning
> as no where part.
>=20
> Generally I'm not sure that having a layout rule which says that {} is
> inserted when the next indentation level is about to start and the new
> indent is smaller than the outer one is necessary; in all useful cases
> the keyword which triggered the layout could be omitted, and writing
>     let x =3D case x of
>       foo -> ...
> should be either an error or it should be allowed to have the next
> indent smaller than the previous one - it's not useful to let it mean
>     let {x =3D case x of {}}
>       foo -> ...
> and in case one really wants to have empty alts in case, he=20
> can write {}
> explicitly.

I agree, but this isn't really a bug so there's no need to change the
report.  Besides, GHC is the only compiler which actually implements the
layout rule as specified :-)

Cheers,
	Simon