[clean up IO routines in standard libraries some.
John Meacham <john@repetae.net>**20060221112645] hunk ./Name/Names.hs 123
-    func_runMain = toName Val ("Prelude.IO","runMain"),
+    func_runMain = toName Val ("Jhc.IO","runMain"),
hunk ./Name/Names.hs 127
-    func_runExpr = toName Val ("Prelude.IO","runExpr"),
+    func_runExpr = toName Val ("Jhc.IO","runExpr"),
hunk ./lib/Jhc/IO.hs 1
-module Jhc.IO where
+module Jhc.IO(
+    IO(..),
+    IOResult(..),
+    World__(),
+    catch,
+    drop__,
+    newWorld__,
+    fixIO,
+    ioError,
+    runExpr,
+    runMain,
+    undefinedIOErrorCont,
+    unsafeInterleaveIO,
+    unsafePerformIO
+    ) where
hunk ./lib/Jhc/IO.hs 100
+{-# INLINE runMain, runExpr #-}
+runMain :: IO a -> IO ()
+runMain main = do
+    catch main  (\e -> do
+        putStr "\nError..\n"
+        putStrLn $ showIOError e
+        return (error "runMain"))
+    return ()
+
+runExpr :: Show a => a -> IO ()
+runExpr x = runMain (print x)
hunk ./lib/Prelude/IO.hs 24
-{-# INLINE runMain, runExpr, ioError, catch #-}
-runMain :: IO a -> IO ()
---runMain main = do
---    main
---    return ()
---runMain (IO main) = IO $ \w-> case main w of JustIO w' _ -> JustIO w' ()
-runMain main = do
-    catch main  (\e -> do
-        putStr "\nError..\n"
-        putStrLn $ showIOError e
-        return (error "runMain"))
-    return ()
-
-runExpr :: Show a => a -> IO ()
-runExpr x = runMain (print x)
-
-
hunk ./lib/Prelude/IO.hs 53
-{-
-getContents :: IO String
-getContents = return (unsafePerformIO getContents') where
-    getContents' = do
-        ch <- c_getwchar
-        case ch of
-            -1 -> return []
-            _ -> return (chr (fromIntegral ch):unsafePerformIO getContents')
--}
hunk ./lib/Prelude/IO.hs 67
-read_str = unsafePerformIO (newCString "r")
-
-foreign import primitive "integralCast" cwintToChar :: CWint -> Char
hunk ./lib/Prelude/IO.hs 71
-foreign import ccall "wchar.h getwchar" c_getwchar :: IO CWint
hunk ./lib/Prelude/IO.hs 110
-putChar c = c_putwchar (fromIntegral (ord c))
+putChar c = c_putwchar (charToCWchar c)
hunk ./lib/Prelude/IO.hs 120
-foreign import ccall "stdio.h putwchar" c_putwchar :: CWchar -> IO ()
---foreign import ccall "stdio.h getchar_unlocked" c_getchar :: IO CInt
+foreign import primitive "const.\"r\"" read_str :: Ptr CChar
hunk ./lib/Prelude/IO.hs 122
---putChar c = IO $ primPutChar c
---getChar = IO primGetChar
+foreign import primitive "integralCast" cwintToChar :: CWint -> Char
+foreign import primitive "integralCast" charToCWchar :: Char -> CWchar
hunk ./lib/Prelude/IO.hs 125
---foreign import primitive primPutChar :: Char -> World__ -> IOResult ()
---foreign import primitive primGetChar :: World__ -> IOResult Char
+foreign import ccall "stdio.h putwchar" c_putwchar :: CWchar -> IO ()
+foreign import ccall "wchar.h getwchar" c_getwchar :: IO CWint
hunk ./lib/System.hs 12
-            --    deriving (Eq, Ord, Read, Show)
+            deriving (Eq, Ord, Read, Show)
hunk ./lib/System.hs 22
---getArgs = return []
---getProgName = return "(jhc)"
---getEnv _ = return ""
-
hunk ./lib/System.hs 43
-{-
-getEnv s = case lookup s theEnvironment of
-    Just y -> return y
-    Nothing -> fail $ "getEnv: " ++ s
-
-theEnvironment :: [(String,String)]
-theEnvironment = unsafePerformIO $ do
-    ep <- peek c_environ
-    --let f xs ptr | ptr == nullPtr = return xs
-    --    f xs ptr = do
-    --        cs <- peekCString ptr
-    --        let (x,y) = span (/= '=') cs
-    --        return ((x,drop 1 y):xs)
-    xs <- mapM peekCString $ takeWhile (/= nullPtr) (iterate (`plusPtr` sizeOf (undefined :: CString)) ep)
-    let g xs = (x,drop 1 y) where (x,y) = span (/= '=') xs
-    return $ map g xs
-    -}
hunk ./lib/System.hs 48
---foreign import primitive getArgs' :: World__ -> IOResult [String]
hunk ./lib/System.hs 55
---foreign import ccall "&environ" c_environ :: (Ptr (Ptr CString))