Read for integral types: proposed semantic change

wren romano winterkoninkje at
Sun Oct 9 05:08:46 UTC 2016

I totally agree that the desired semantics should be:

> readsInt "12e-3" = [12,"e-3"] -- yes, there is an int at the beginning of the string.
> readsInt ('a' : ...) = [] -- yes, we can tell there isn't an int at the beginning of the string.

In terms of algorithms for parsing things efficiently as well as
failing fast, I highly recommend looking at what bytestring-lexing
does. Though the implementations there read in ByteStrings, there's
nothing about the algorithms that depends on that representation.
Getting efficient (and correct!) parsing for Fractional types is quite
a lot more complicated than it looks on the surface.

Live well,

More information about the Libraries mailing list