[Haskell-cafe] Correct parsers for bounded integral values
Jeff Clites
jclites at mac.com
Mon Jul 21 17:42:09 UTC 2025
> On Jul 21, 2025, at 8:43 AM, Stefan Klinger <haskell at stefan-klinger.de> wrote:
>
> Hallo, and thanks for the discussion!
You are welcome!
> But there is a *different* read function
>
> read :: String -> Word8
>
> which is not used in the scenario above, and this is the buggy one
> (and all its bounded cousins).
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).
But I could be wrong about the intention in the other cases, you can always ask the relevant committee.
(BTW the `read` functions have other quirks, like allowing leading whitespace.)
Jeff Clites
More information about the Haskell-Cafe
mailing list