[Haskell-cafe] Re: Write Haskell as fast as C.
bertram.felgenhauer at googlemail.com
Sun May 18 14:22:38 EDT 2008
Andrew Coppin wrote:
> I think you'll find the code that GHC derives for a Read instance handles
> extra whitespace and all kinds of other whatnot that you don't actually
> need in this specific case. I suspect this is what's up - but I don't have
> any hard proof for that. ;-)
Parentheses are handled as well.
It's worse than that - derived read instances are defined in terms of
'lex' (via lexP in GHC.Read) which, among other things, recognizes
numerical and string constants. The latter has the odd effect that
with the following declaration,
> data A = A deriving (Read, Show)
the expression read ('"' : repeat ' ') :: A is the wrong kind of
bottom - instead of a parse error, you get an infinite loop.
More information about the Haskell-Cafe