X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=System%2FIO.hs;h=d6bc1eede63f86f052d36cf1e10d6cd30f3d7cc6;hb=6075d5f981bbe94387a8322de1b516968dcc000b;hp=e25d422fb839e7a347ed609eba928f0c24734527;hpb=9812e0a321ec0ed8f9e53eb2febfb14c79564200;p=haskell-directory.git diff --git a/System/IO.hs b/System/IO.hs index e25d422..d6bc1ee 100644 --- a/System/IO.hs +++ b/System/IO.hs @@ -35,7 +35,7 @@ module System.IO ( hGetPosn, -- :: Handle -> IO HandlePosn hSetPosn, -- :: HandlePosn -> IO () hSeek, -- :: Handle -> SeekMode -> Integer -> IO () -#ifndef __HUGS__ +#if !defined(__NHC__) hTell, -- :: Handle -> IO Integer #endif hWaitForInput, -- :: Handle -> Int -> IO Bool @@ -62,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, @@ -89,14 +85,14 @@ module System.IO ( readIO, -- :: Read a => String -> IO a readLn, -- :: Read a => IO a -#ifndef __HUGS__ +#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 -#ifndef __HUGS__ +#if !defined(__HUGS__) && !defined(__NHC__) hSetEcho, -- :: Handle -> Bool -> IO () hGetEcho, -- :: Handle -> IO Bool @@ -121,6 +117,53 @@ 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 -- ----------------------------------------------------------------------------- @@ -201,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