
Thomas Hallgren
module Rebind where f x = x where x = True
nhc98-1.16 [1] produces the error message
====== Errors when renaming: Redefinition of Identifier x at 5:5
While this is not completely unreasonable, it seems to be a deviation from the Haskell 98 report and the behaviour of other Haskell implementations.
It is quite difficult to be sure exactly what the Haskell Report says on this matter, but I think you are probably right. There is no explicit section giving the semantics of `where' clauses at all! As you say though, there is one rule in the formal semantics for pattern matching that translates a `where' clause to a `let' binding. However, I do not propose to fix this bug in nhc98. The example you give is extremely likely to be a programmer's mistake, so in my opinion the error message from the compiler is more useful than the strange runtime behaviour that might otherwise occur. When the rebinding is deliberate, it is easy for the author to find a different way of coding the intended semantics. Regards, Malcolm