[Haskell-cafe] reading and writing Data.Ratio.Rational

wren romano winterkoninkje at gmail.com
Sun Mar 12 23:21:21 UTC 2017

If you're concerned about performance, you should take a look at
bytestring-lexing[1]. The `readDecimal` function does the basic "parse
as a pair of ints then divide" trick, whereas `readDecimalLimited`
does some other tricks to take advantage of types with limited
precision— but which can still give massive performance improvements
for types with unlimited precision, in certain circumstances. If you
want to read the exponential notation rather than just the decimal
notation, then there's also `readExponential` and
`readExponentialLimited`. And there are benchmarks[2] comparing them
to other parsing/lexing libraries.

[1] <http://hackage.haskell.org/package/bytestring-lexing->

[2] <http://community.haskell.org/~wren/bytestring-lexing/bench/html/>

Live well,

More information about the Haskell-Cafe mailing list