[Haskell-cafe] Reading integers

Bertram Felgenhauer bertram.felgenhauer at googlemail.com
Thu Sep 7 13:27:52 EDT 2006


Hi,

I've implemented replacements for readsPrec for Int and Integer in
a module called Compat (in my darcs repository [1]) and measured
their performance.

There's some overhead when compared to the plain versions.
For Integer, it's about 30% for single digit numbers, going down
to about 10% at 10 digits, and about 1.3% at 100.

It's still a big win over the existing instances at a small loss
in compatibility to Haskell 98. As far as I can make out, the only
difference is that it fails to diverge in some cases where reads
would diverge (see my initial mail for an example.)


I've also received a question from Ketil Malde off list, asking
(in reply to Neil Mitchell) what the advantages would be of having
this in base.

Personally I think it should go into base if we can agree on replacing
existing code (the Read instances or something in Numeric or maybe both).
This would have the advantage of making quite a few programs more
efficient just by recompiling them.

If we can't agree on that, the code will be made available as an extra
module but I wouldn't see any advantage at having it in base. Having
it distributed with ghc would have some advantages (mainly convenience
for users and a slightly better chance of avoiding forks).


In other news, darcs send will now send the patches to me - in case
anyone has any.

regards,

Bertram

[1] I'll say again that browsing directly doesn't work, darcs is fine
though, get the code with
    darcs get http://int-e.home.tlink.de/haskell/readinteger


More information about the Haskell-Cafe mailing list