
Hi, As the following script shows, hexa-decimal digits cannot be recognized by 'Prelude.read'. It seems to be a bug. Regards, Kwanghoon Choi ================================================ [khchoi@www] 37 % cat Test.hs module Main where import Char main = do { putStrLn (show (chr (read "0x2B" :: Int))) } [khchoi@www] 39 % nhc98 -o test Test.hs [khchoi@www] 40 % ./test Prelude.read: no parse [khchoi@www] 41 %

Kwanghoon Choi
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 respectively. Arguably, this is a bug in the Haskell'98 definition, but both nhc98 and Hugs follow the definition exactly in this case. Regards, Malcolm
participants (2)
-
Kwanghoon Choi
-
Malcolm Wallace