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.

Bertram
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to