I believe it's not that integers must wrap, but that Read behavior must
match compiler behavior (and GHC's behavior is to wrap).
On Sun, Aug 3, 2025, 12:17 PM Stefan Klinger
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...
-- 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. _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.