[Haskell] Re: Parsing bug in GHC 6.4.1 ?

Cale Gibbard cgibbard at gmail.com
Sun Jan 8 11:23:46 EST 2006


On 08/01/06, Bruno Oliveira <bruno.oliveira at comlab.ox.ac.uk> wrote:
> On 08 Jan 2006 16:37:47 +0100, Peter Simons wrote:
>
> >Bruno Oliveira writes:
>
> > >> class Foo o where
> > >>   (:+) :: o -> o -> o
>
> >The Haskell report specifies in section "2.4 Identifiers and
> >Operators":
>
> >  An operator symbol starting with a colon is a constructor.
>
> >Think of ':' as a character that is interpreted as "uppercase";
> >you can't use it to start a function or variable name.
>
> Then this declaration should be rejected as invalid, right?
>
> That's why I think this is a parsing bug...
>
> Cheers,
>
> Bruno

Hmm... yeah, it does seem like a parsing bug. The relevant rules from
the report are:

----
topdecl 	 -> ...
	| 	class [scontext =>] tycls tyvar [where cdecls]
	...

cdecls 	 -> 	 { cdecl1 ; ... ; cdecln } 	 (n>=0)
cdecl 	-> 	gendecl
	| ...

gendecl 	 -> 	 vars :: [context =>] type 	 (type signature)
	| ...

vars 	 -> 	 var1 , ..., varn 	 (n>=1)

var 	 -> 	 varid | ( varsym )

varsym 	 -> 	 ( symbol {symbol | :})<reservedop | dashes>
----

So it should not be permitting a type declaration for something
starting with a colon, since symbol does not match colon.


More information about the Haskell mailing list