[Hat] Hat bug report: incorrectly lexing "__"

Fergus Henderson fjh007 at galois.com
Tue Jun 29 16:44:05 EDT 2004


Hat mishandles programs containing "__".

	bash$ cat Foo.hs
	f :: Int -> Int
	f __ = 42

	bash$ hmake -hat Foo
	hat-trans  Foo.hs

	Fail: expandTypeSynonym: Int is not a type synonym

The problem here seems to be that Hat is lexing "__" as two tokens,
rather than one.

The Haskell 98 report says

 | 	Lexical analysis should use the "maximal munch" rule: at
 | 	each point, the longest possible lexeme satisfying the lexeme
 | 	production is read.

so "__" should be parsed as a single token, not two tokens.
Note that in the Haskell 98 grammar, the lexical category "small"
includes the underscore character.

This bug is very easy to work around, of course.
I'm just reporting it for your information.

Cheers,
	Fergus.

-- 
Fergus J. Henderson                 |  "I have always known that the pursuit
Galois Connections, Inc.            |  of excellence is a lethal habit"
Phone: +1 503 626 6616              |     -- the last words of T. S. Garp.


More information about the Hat mailing list