[nhc-bugs] read "hexadecimal digits"?
Malcolm.Wallace at cs.york.ac.uk
Mon May 31 06:19:14 EDT 2004
Kwanghoon Choi <khchoi at jaist.ac.jp> writes:
> As the following script shows, hexa-decimal digits
> cannot be recognized by 'Prelude.read'.
> It seems to be a bug.
> main = putStrLn (show (chr (read "0x2B" :: Int)))
Actually, it is conformant Haskell'98 behaviour. The Prelude defines
instance Read Int where
readsPrec p = readSigned readDec
(or a very near equivalent), that is, it uses readDec for decimal
notation, rather than using readOct or readHex for octal or hexadecimal
Arguably, this is a bug in the Haskell'98 definition, but both nhc98
and Hugs follow the definition exactly in this case.
More information about the Nhc-bugs