Skip to content

Parsing of lambdas is not consistent with Haskell'98 report.

Consider the following expression:

(\x -> x :: Int . id)

GHC (without any -X flags) currently reports a parse error:

Illegal operator .' in type Int . id'[[br]] Use -XTypeOperators to allow operators in types

However, I think this expression is legal in Haskell'98 (and indeed still legal in Haskell 2010). The report gives an (ambiguous) expression grammar, which (unambiguously) parses the above as (\x -> (x :: Int)) . id. The report further says that lambdas extend as far as possible to the right, but the parse which GHC is using is not a possible parse according to the grammar, since infix operators (other than "->") are not allowed in the construction 'type'.

That said, I'd much rather see this fixed in the Haskell 2011 report than in GHC :)

Trac metadata
Trac field Value
Version 6.10.4
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler (Parser)
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information