Re: read "hexadecimal digits"?
Malcolm Wallace <[email protected]> Mon, 31 May 2004 11:19:14 +0100
| Newsgroups | gmane.comp.lang.haskell.nhc.bugs |
|---|---|
| Organization | Dept of Computer Science, University of York |
| Message-ID | <[email protected]> |
Kwanghoon Choi <[email protected]> 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 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