strict-io-0.1: A library wrapping standard IO modules to provide strict IO.Source codeContentsIndex
System.IO.Strict
Stabilityprovisional
MaintainerNicolas Pouillard <nicolas.pouillard@gmail.com>
Contents
Types
Functions stricter than there System.IO counterparts
Functions as strict as there System.IO counterparts
Description

This module wraps the functions of the System.IO module at a different type namely SIO.

The purpose of this module is to export only strict IO functions, by strict we mean strict in the result. The arguments of these functions may only by partially forced, but when the function returns, the arguments can no longer be forced by the function. When the type of the value to be forced is polymorphic, a NFData constraint is added since we (internally) use rnf to force the value. Then we rely on the behavior of NFData instances to provide the fact that any lazy argument passed to a SIO function will not leak-out after the call.

These functions do not necessarily use their arguments completely but they do not hold or return any value that could depend on these arguments. If the original functions from System.IO module were already strict, then this module just provides them at another type. Some functions from the original module are famously lazy like the getContents like functions: in this module their results are deeply forced.

In Haskell, monad operations (return and >>=) have to be lazy. Therefore the SIO monad is not completely strict (i.e. pure values can still be lazy). So in this module we expose the return' function that forces the given value before putting it into the monad.

Since this module uses the same names as System.IO, it is designed to be imported qualified.

    import System.IO.Strict (SIO)
    import qualified System.IO.Strict as SIO
Synopsis
data SIO a
run :: NFData sa => SIO sa -> IO sa
return' :: (Monad m, NFData sa) => sa -> m sa
getContents :: SIO String
hGetContents :: Handle -> SIO String
readFile :: FilePath -> SIO String
read :: (NFData sa, Read sa) => String -> SIO sa
readLn :: (NFData sa, Read sa) => SIO sa
fix :: NFData sa => (sa -> SIO sa) -> SIO sa
withBinaryFile :: NFData sr => FilePath -> IOMode -> (Handle -> SIO sr) -> SIO sr
withFile :: NFData sr => FilePath -> IOMode -> (Handle -> SIO sr) -> SIO sr
appendFile :: FilePath -> String -> SIO ()
getChar :: SIO Char
getLine :: SIO String
hPrint :: Show a => Handle -> a -> SIO ()
hPutStrLn :: Handle -> String -> SIO ()
hReady :: Handle -> SIO Bool
interact :: (String -> String) -> SIO ()
openBinaryTempFile :: FilePath -> String -> SIO (FilePath, Handle)
openTempFile :: FilePath -> String -> SIO (FilePath, Handle)
print :: Show a => a -> SIO ()
putChar :: Char -> SIO ()
putStr :: String -> SIO ()
putStrLn :: String -> SIO ()
writeFile :: FilePath -> String -> SIO ()
hClose :: Handle -> SIO ()
hFileSize :: Handle -> SIO Integer
hFlush :: Handle -> SIO ()
hGetBuf :: Handle -> Ptr a -> Int -> SIO Int
hGetBufNonBlocking :: Handle -> Ptr a -> Int -> SIO Int
hGetBuffering :: Handle -> SIO BufferMode
hGetChar :: Handle -> SIO Char
hGetEcho :: Handle -> SIO Bool
hGetLine :: Handle -> SIO String
hGetPosn :: Handle -> SIO HandlePosn
hIsClosed :: Handle -> SIO Bool
hIsEOF :: Handle -> SIO Bool
hIsOpen :: Handle -> SIO Bool
hIsReadable :: Handle -> SIO Bool
hIsSeekable :: Handle -> SIO Bool
hIsTerminalDevice :: Handle -> SIO Bool
hIsWritable :: Handle -> SIO Bool
hLookAhead :: Handle -> SIO Char
hPutBuf :: Handle -> Ptr a -> Int -> SIO ()
hPutBufNonBlocking :: Handle -> Ptr a -> Int -> SIO Int
hPutChar :: Handle -> Char -> SIO ()
hPutStr :: Handle -> String -> SIO ()
hSeek :: Handle -> SeekMode -> Integer -> SIO ()
hSetBinaryMode :: Handle -> Bool -> SIO ()
hSetBuffering :: Handle -> BufferMode -> SIO ()
hSetEcho :: Handle -> Bool -> SIO ()
hSetFileSize :: Handle -> Integer -> SIO ()
hSetPosn :: HandlePosn -> SIO ()
hShow :: Handle -> SIO String
hTell :: Handle -> SIO Integer
hWaitForInput :: Handle -> Int -> SIO Bool
isEOF :: SIO Bool
openBinaryFile :: FilePath -> IOMode -> SIO Handle
openFile :: FilePath -> IOMode -> SIO Handle
stderr :: Handle
stdin :: Handle
stdout :: Handle
Types
data SIO a Source
show/hide Instances
run :: NFData sa => SIO sa -> IO saSource
run allows to return to the wider world of IOs.
return' :: (Monad m, NFData sa) => sa -> m saSource
A stricter version of return, that works for every monad.
Functions stricter than there System.IO counterparts
getContents :: SIO StringSource
Note that getContents is stricter than its counterpart in System.IO.
hGetContents :: Handle -> SIO StringSource
Note that hGetContents is stricter than its counterpart in System.IO.
readFile :: FilePath -> SIO StringSource
Note that readFile is stricter than its counterpart in System.IO.
read :: (NFData sa, Read sa) => String -> SIO saSource
Note that read is stricter than its counterpart in System.IO.
readLn :: (NFData sa, Read sa) => SIO saSource
Note that readLn is stricter than its counterpart in System.IO.
fix :: NFData sa => (sa -> SIO sa) -> SIO saSource
Note that fix is stricter than its counterpart in System.IO.
withBinaryFile :: NFData sr => FilePath -> IOMode -> (Handle -> SIO sr) -> SIO srSource
Note that withBinaryFile is stricter than its counterpart in System.IO.
withFile :: NFData sr => FilePath -> IOMode -> (Handle -> SIO sr) -> SIO srSource
Note that withFile is stricter than its counterpart in System.IO.
Functions as strict as there System.IO counterparts
appendFile :: FilePath -> String -> SIO ()Source
getChar :: SIO CharSource
getLine :: SIO StringSource
hPrint :: Show a => Handle -> a -> SIO ()Source
hPutStrLn :: Handle -> String -> SIO ()Source
hReady :: Handle -> SIO BoolSource
interact :: (String -> String) -> SIO ()Source
openBinaryTempFile :: FilePath -> String -> SIO (FilePath, Handle)Source
openTempFile :: FilePath -> String -> SIO (FilePath, Handle)Source
print :: Show a => a -> SIO ()Source
putChar :: Char -> SIO ()Source
putStr :: String -> SIO ()Source
putStrLn :: String -> SIO ()Source
writeFile :: FilePath -> String -> SIO ()Source
hClose :: Handle -> SIO ()Source
hFileSize :: Handle -> SIO IntegerSource
hFlush :: Handle -> SIO ()Source
hGetBuf :: Handle -> Ptr a -> Int -> SIO IntSource
hGetBufNonBlocking :: Handle -> Ptr a -> Int -> SIO IntSource
hGetBuffering :: Handle -> SIO BufferModeSource
hGetChar :: Handle -> SIO CharSource
hGetEcho :: Handle -> SIO BoolSource
hGetLine :: Handle -> SIO StringSource
hGetPosn :: Handle -> SIO HandlePosnSource
hIsClosed :: Handle -> SIO BoolSource
hIsEOF :: Handle -> SIO BoolSource
hIsOpen :: Handle -> SIO BoolSource
hIsReadable :: Handle -> SIO BoolSource
hIsSeekable :: Handle -> SIO BoolSource
hIsTerminalDevice :: Handle -> SIO BoolSource
hIsWritable :: Handle -> SIO BoolSource
hLookAhead :: Handle -> SIO CharSource
hPutBuf :: Handle -> Ptr a -> Int -> SIO ()Source
hPutBufNonBlocking :: Handle -> Ptr a -> Int -> SIO IntSource
hPutChar :: Handle -> Char -> SIO ()Source
hPutStr :: Handle -> String -> SIO ()Source
hSeek :: Handle -> SeekMode -> Integer -> SIO ()Source
hSetBinaryMode :: Handle -> Bool -> SIO ()Source
hSetBuffering :: Handle -> BufferMode -> SIO ()Source
hSetEcho :: Handle -> Bool -> SIO ()Source
hSetFileSize :: Handle -> Integer -> SIO ()Source
hSetPosn :: HandlePosn -> SIO ()Source
hShow :: Handle -> SIO StringSource
hTell :: Handle -> SIO IntegerSource
hWaitForInput :: Handle -> Int -> SIO BoolSource
isEOF :: SIO BoolSource
openBinaryFile :: FilePath -> IOMode -> SIO HandleSource
openFile :: FilePath -> IOMode -> SIO HandleSource
stderr :: HandleSource
stdin :: HandleSource
stdout :: HandleSource
Produced by Haddock version 2.6.0