RE: GHC's readLitChar does not conform to 98

Excellent point, thank you. A bogon. Fixed in the HEAD, and a regression test added Simon | -----Original Message----- | From: Akim Demaille [mailto:akim@epita.fr] | Sent: 05 March 2003 13:50 | To: glasgow-haskell-users@haskell.org | | Hi! | | I believe the implementation of readLitChar (and lexLitChar) does not | conform to the documentation, and this results in GHC and Hugs | disagreeing on the following code: | | ---------------------------------------- | module Main (main) | where | | import IO (stderr, hPutStrLn) | import Char (digitToInt, lexLitChar, readLitChar) | | main :: IO () | main = | do hPutStrLn stderr (show $ readLitChar "A") | hPutStrLn stderr (show $ readLitChar "'A'") | ---------------------------------------- | | ghc says: | | /tmp % ghc --version nostromo 14:45 | The Glorious Glasgow Haskell Compilation System, version 5.04.2 | /tmp % /tmp/a.out nostromo 14:46 | [] | [('A',"")] | | | and Hugs says: | | /tmp % runhugs Main.hs nostromo Err 1 | [('A',"")] | [('\'',"A'")] | | | The doc seems to agree with Hugs (thanks to sebc for the pointer): | | http://www.haskell.org/onlinereport/char.html | | > The function showLitChar converts a character to a string using only | > printable characters, using Haskell source-language escape | > conventions. The function lexLitChar does the reverse, returning the | > sequence of characters that encode the character. The function | > readLitChar does the same, but in addition converts the to the | > character that it encodes. For example: | > | > showLitChar '\n' s = "\\n" ++ s | > lexLitChar "\\nHello" = [("\\n", "Hello")] | > readLitChar "\\nHello" = [('\n', "Hello")] | _______________________________________________ | Glasgow-haskell-users mailing list | Glasgow-haskell-users@haskell.org | http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
participants (1)
-
Simon Peyton-Jones