[Haskell-cafe] Correct parsers for bounded integral values
Stefan Klinger
haskell at stefan-klinger.de
Sun Aug 3 19:17:20 UTC 2025
Pierre Thierry (2025-Jul-21, excerpt):
> Well, IIUC, it conforms to the Haskell 98 specification.
Hm. Maybe I keep missing something here. After all it's beeing
pointed out repeatedly by you guys (and yes, I do listen), but I fail
to verify that claim.
I don't think the Haskell Spec really *requires* the `read` function
for a bounded integral type to wrap around.
Jeff Clites via Haskell-Cafe (2025-Jul-21, excerpt):
> I think you will find, though, that `read @Word8` is intended to
> match the behavior of `(fromInteger @Word8) . (read @Integer)`. At
> least, the `Int` case is specified in the Haskell Report (in the
> Prelude implementation).
Sorry, I cannot find this. Would you have a URL and a line number for
me? I'm really sorry my google-foo seems to be insufficient.
I have found in the 98 report [4], similar in 2010 [5]:
The results of exceptional conditions (such as overflow or
underflow) on the fixed-precision numeric types are undefined; an
implementation may choose error (_|_, semantically), a truncated
value, or a special value such as infinity, indefinite, etc.
So, not violating the report, but the implementation might choose to
do better.
Cheers
Stefan
[1]: https://mail.haskell.org/pipermail/haskell-cafe/2025-July/137156.html
[2]: https://mail.haskell.org/pipermail/haskell-cafe/2025-July/137155.html
[3]: https://mail.haskell.org/pipermail/haskell-cafe/2025-July/137162.html
[4]: https://www.haskell.org/onlinereport/basic.html#sect6.4
[5]: https://www.haskell.org/onlinereport/haskell2010/haskellch6.html#x13-1350006.4
--
Stefan Klinger, Ph.D. -- computer scientist o/X
http://stefan-klinger.de /\/
https://github.com/s5k6 \
I prefer receiving plain text messages, not exceeding 32kB.
More information about the Haskell-Cafe
mailing list