18 May 20:22
Re: Re: Write Haskell as fast as C.
From: Bertram Felgenhauer <bertram.felgenhauer <at> googlemail.com>
Subject: Re: Re: Write Haskell as fast as C.
Newsgroups: gmane.comp.lang.haskell.cafe
Date: 2008-05-18 18:22:38 GMT
Subject: Re: Re: Write Haskell as fast as C.
Newsgroups: gmane.comp.lang.haskell.cafe
Date: 2008-05-18 18:22:38 GMT
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
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
RSS Feed