X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=System%2FIO.hs;h=d6bc1eede63f86f052d36cf1e10d6cd30f3d7cc6;hb=6075d5f981bbe94387a8322de1b516968dcc000b;hp=904082cb95fec265c2e18d0325a89c4394e70509;hpb=f7a485978f04e84b086f1974b88887cc72d832d0;p=ghc-base.git diff --git a/System/IO.hs b/System/IO.hs index 904082c..d6bc1ee 100644 --- a/System/IO.hs +++ b/System/IO.hs @@ -35,7 +35,9 @@ module System.IO ( hGetPosn, -- :: Handle -> IO HandlePosn hSetPosn, -- :: HandlePosn -> IO () hSeek, -- :: Handle -> SeekMode -> Integer -> IO () +#if !defined(__NHC__) hTell, -- :: Handle -> IO Integer +#endif hWaitForInput, -- :: Handle -> Int -> IO Bool hReady, -- :: Handle -> IO Bool hGetChar, -- :: Handle -> IO Char @@ -60,12 +62,8 @@ module System.IO ( ioeGetFileName, -- :: IOError -> Maybe FilePath try, -- :: IO a -> IO (Either IOError a) - bracket, -- :: IO a -> (a -> IO b) -> (a -> IO c) -> IO c - bracket_, -- :: IO a -> (a -> IO b) -> IO c -> IO c - -- Non-standard extension (but will hopefully become standard with 1.5) is - -- to export the Prelude io functions via IO (in addition to exporting them - -- from the prelude...for now.) + -- re-exports of Prelude names IO, -- instance MonadFix FilePath, -- :: String IOError, @@ -87,15 +85,19 @@ module System.IO ( readIO, -- :: Read a => String -> IO a readLn, -- :: Read a => IO a +#if !defined(__HUGS__) && !defined(__NHC__) hPutBuf, -- :: Handle -> Ptr a -> Int -> IO () hGetBuf, -- :: Handle -> Ptr a -> Int -> IO Int +#endif fixIO, -- :: (a -> IO a) -> IO a +#if !defined(__HUGS__) && !defined(__NHC__) hSetEcho, -- :: Handle -> Bool -> IO () hGetEcho, -- :: Handle -> IO Bool hIsTerminalDevice, -- :: Handle -> IO Bool +#endif ) where #ifdef __GLASGOW_HASKELL__ @@ -110,11 +112,64 @@ import GHC.Read import GHC.Show #endif +#ifdef __HUGS__ +import Hugs.IO +import Hugs.IOExts +#endif + +#ifdef __NHC__ +import IO + ( Handle () + , HandlePosn () + , IOMode (ReadMode,WriteMode,AppendMode,ReadWriteMode) + , BufferMode (NoBuffering,LineBuffering,BlockBuffering) + , SeekMode (AbsoluteSeek,RelativeSeek,SeekFromEnd) + , stdin, stdout, stderr + , openFile -- :: FilePath -> IOMode -> IO Handle + , hClose -- :: Handle -> IO () + , hFileSize -- :: Handle -> IO Integer + , hIsEOF -- :: Handle -> IO Bool + , isEOF -- :: IO Bool + , hSetBuffering -- :: Handle -> BufferMode -> IO () + , hGetBuffering -- :: Handle -> IO BufferMode + , hFlush -- :: Handle -> IO () + , hGetPosn -- :: Handle -> IO HandlePosn + , hSetPosn -- :: HandlePosn -> IO () + , hSeek -- :: Handle -> SeekMode -> Integer -> IO () + , hWaitForInput -- :: Handle -> Int -> IO Bool + , hGetChar -- :: Handle -> IO Char + , hGetLine -- :: Handle -> IO [Char] + , hLookAhead -- :: Handle -> IO Char + , hGetContents -- :: Handle -> IO [Char] + , hPutChar -- :: Handle -> Char -> IO () + , hPutStr -- :: Handle -> [Char] -> IO () + , hIsOpen, hIsClosed -- :: Handle -> IO Bool + , hIsReadable, hIsWritable -- :: Handle -> IO Bool + , hIsSeekable -- :: Handle -> IO Bool + , isAlreadyExistsError, isDoesNotExistError -- :: IOError -> Bool + , isAlreadyInUseError, isFullError + , isEOFError, isIllegalOperation + , isPermissionError, isUserError + , ioeGetErrorString -- :: IOError -> String + , ioeGetHandle -- :: IOError -> Maybe Handle + , ioeGetFileName -- :: IOError -> Maybe FilePath + + , IO () + , FilePath -- :: String + , IOError + , ioError -- :: IOError -> IO a + , userError -- :: String -> IOError + , catch -- :: IO a -> (IOError -> IO a) -> IO a + ) +import NHC.Internal (unsafePerformIO) +#endif + import System.IO.Error -- ----------------------------------------------------------------------------- -- Standard IO +#ifndef __HUGS__ putChar :: Char -> IO () putChar c = hPutChar stdout c @@ -169,6 +224,7 @@ readIO s = case (do { (x,t) <- reads s ; [x] -> return x [] -> ioError (userError "Prelude.readIO: no parse") _ -> ioError (userError "Prelude.readIO: ambiguous parse") +#endif /* __HUGS__ */ hReady :: Handle -> IO Bool hReady h = hWaitForInput h 0 @@ -188,3 +244,7 @@ hPrint hdl = hPutStrLn hdl . show fixIO :: (a -> IO a) -> IO a fixIO m = stToIO (fixST (ioToST . m)) #endif +#ifdef __NHC__ +fixIO :: (a -> IO a) -> IO a +fixIO f = let x = unsafePerformIO (f x) in return x +#endif