
On Tue, Mar 15, 2005 at 10:44:28AM +0000, Ross Paterson wrote:
You can select binary I/O using the openBinaryFile and hSetBinaryMode functions from System.IO. After that, the Chars you get from that Handle are actually bytes.
What about the ones sent to it? Are all the following results intentional? Am I doing something stupid? [in brief: hugs' (hPutStr h) now behaves differently to (mapM_ (hPutChar h)), and ghc writes the empty string for both when told to write "\128"] Running the following with new ghc 6.4 and hugs 20050308 or 20050317: echo 'import System.IO; import System.Environment; main = do [o] <- getArgs; ho <- openBinaryFile o WriteMode; hPutStr ho "\128"' > run1.hs echo 'import System.IO; import System.Environment; main = do [o] <- getArgs; ho <- openBinaryFile o WriteMode; mapM_ (hPutChar ho) "\128"' > run2.hs runhugs run1.hs hugs1 runhugs run2.hs hugs2 runghc run1.hs ghc1 runghc run2.hs ghc2 ls -l hugs1 hugs2 ghc1 ghc2 for f in hugs1 hugs2 ghc1 ghc2; do echo $f; hexdump -C $f; done gives: -rw-r--r-- 1 igloo igloo 0 Mar 17 06:15 ghc1 -rw-r--r-- 1 igloo igloo 0 Mar 17 06:15 ghc2 -rw-r--r-- 1 igloo igloo 1 Mar 17 06:15 hugs1 -rw-r--r-- 1 igloo igloo 1 Mar 17 06:15 hugs2 hugs1 00000000 3f |?| 00000001 hugs2 00000000 80 |.| 00000001 ghc1 ghc2 With ghc 6.2.2 and hugs "November 2003" I get: -rw-r--r-- 1 igloo igloo 1 Mar 17 06:16 ghc1 -rw-r--r-- 1 igloo igloo 1 Mar 17 06:16 ghc2 -rw-r--r-- 1 igloo igloo 1 Mar 17 06:16 hugs1 -rw-r--r-- 1 igloo igloo 1 Mar 17 06:16 hugs2 hugs1 00000000 80 |.| 00000001 hugs2 00000000 80 |.| 00000001 ghc1 00000000 80 |.| 00000001 ghc2 00000000 80 |.| 00000001 Incidentally, "make check" in CVS hugs said: cd tests && sh testScript | egrep -v '^--( |-----)' ./../src/hugs +q -w -pHugs: static/mod154.hs < /dev/null expected stdout not matched by reality *** static/Loaded.output Fri Jul 19 22:41:51 2002 --- /tmp/runtest11949.3 Thu Mar 17 05:46:05 2005 *************** *** 1,2 **** ! Type :? for help Hugs:[Leaving Hugs] --- 1,3 ---- ! ERROR "static/mod154.hs" - Conflicting exports of entity "sort" ! *** Could refer to Data.List.sort or M.sort Hugs:[Leaving Hugs] Thanks Ian