
9 Oct
2016
9 Oct
'16
1:08 a.m.
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, ~wren