Le 21/07/2025 à 17:42, Stefan Klinger a écrit :
    x = 123456
is equivalent to
    x = fromInteger (read "123456" :: Integer)

It's basically what happens internally. You can see the convertInt function and it's used a few lines beneath in the Read Int instance.

convertInt :: Num a => L.Lexeme -> ReadPrec a
convertInt (L.Number n)
 | Just i <- L.numberToInteger n = return (fromInteger i)
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).
Well, IIUC, it conforms to the Haskell 98 specification. In that sense, it's not buggy. But the specification may be sound and counter-intuitive (which is not an uncommon combination…).

Curiously,
Pierre Thierry
--

pierre@nothos.net
0xD9D50D8A