Robustness of instance Read Char
Fri, 2 Nov 2001 09:26:50 -0800
Simon Peyton-Jones [email protected] writes:
[.. following up to Peter Thiemann's post on the slowness of Read(S) ..]
> I do agree with you that it woud be better for the Read class
> to use a Maybe result rather than a list of parses. But I'm not
> sure your problem can be solved simply by making the Char
> instance of Read better. ....
For what it's worth, I played around with changing ReadS to do
just that a couple of years ago, i.e., defining it as
type ReadS a = String -> Maybe (a,String)
The reductions in space&time were decent (at least 2x in some cases,
if I remember correctly), but I didn't take the idea any further.
It's a simple change - you can enable it by compiling GHC's
PrelRead.lhs with the extra option -DNEW_READS_REP -- there's
no 'deriving' support for this rep. of ReadS in the compiler itself tho.