-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | File handles with explicit IOModes -- -- The module System.IO.ExplicitIOModes exports a -- Handle to a file which is parameterized with the IOMode the -- handle is in. All operations on handles explicitly specify the needed -- IOMode. This way it is impossible to read from a write-only handle or -- write to a read-only handle for example. @package explicit-iomodes @version 0.2 -- | This module exports a Handle to a file which is parameterized -- with the IOMode the handle is in. All operations on handles explicitly -- specify the needed IOMode. This way it is impossible to read from a -- write-only handle or write to a read-only handle for example. -- -- This modules re-exports everything from System.IO so you can -- just replace: import System.IO with: import -- System.IO.ExplicitIOModes, change some type signatures and expect -- everything to type-check. -- -- There's one exception to this last statement: If you are using the -- standard handles stdin, stdout or stderr in a -- mode which isn't their default mode (R for stdin and -- W for stdout and stderr) you have to cast -- these handles to the expected IOMode. module System.IO.ExplicitIOModes -- | A value of type IO a is a computation which, when -- performed, does some I/O before returning a value of type a. -- -- There is really only one way to "perform" an I/O action: bind it to -- Main.main in your program. When your program is run, the I/O -- will be performed. It isn't possible to perform I/O from an arbitrary -- function, unless that function is itself in the IO monad and -- called at some point, directly or indirectly, from Main.main. -- -- IO is a monad, so IO actions can be combined using -- either the do-notation or the >> and >>= operations from -- the Monad class. data IO a :: * -> * fixIO :: (a -> IO a) -> IO a -- | File and directory names are values of type String, whose -- precise meaning is operating system dependent. Files can be opened, -- yielding a handle which can then be used to operate on the contents of -- that file. type FilePath = String -- | A handle to a file with an explicit IOMode. -- -- Wraps: System.IO.Handle. data Handle ioMode -- | Read only. data R -- | Write only. data W -- | Write only by appending. data A -- | Both read and write. data RW -- | Class of readable IO mode types. class ReadModes ioMode -- | Class of writable IO mode types. class WriteModes ioMode -- | Wraps: System.IO.stdin. stdin :: Handle R -- | Wraps: System.IO.stdout. stdout :: Handle W -- | Wraps: System.IO.stderr. stderr :: Handle W -- | Cast the IOMode of a handle if the handle supports it. cast :: (CheckMode castedIOMode) => Handle anyIOMode -> IO (Maybe (Handle castedIOMode)) class CheckMode ioMode -- | Wraps: System.IO.withFile. withFile :: FilePath -> IOMode ioMode -> (Handle ioMode -> IO α) -> IO α -- | Wraps: System.IO.openFile. openFile :: FilePath -> IOMode ioMode -> IO (Handle ioMode) -- | The IOMode GADT which for each constructor specifies the associated -- IOMode type. -- -- Also see: System.IO.IOMode. data IOMode ioMode ReadMode :: IOMode R WriteMode :: IOMode W AppendMode :: IOMode A ReadWriteMode :: IOMode RW -- | Retrieves the regular System.IO.IOMode. regularIOMode :: IOMode ioMode -> IOMode -- | Wraps: System.IO.hClose. hClose :: Handle ioMode -> IO () -- | The readFile function reads a file and returns the contents of -- the file as a string. The file is read lazily, on demand, as with -- getContents. readFile :: FilePath -> IO String -- | The computation writeFile file str function writes the -- string str, to the file file. writeFile :: FilePath -> String -> IO () -- | The computation appendFile file str function appends -- the string str, to the file file. -- -- Note that writeFile and appendFile write a literal -- string to a file. To write a value of any printable type, as with -- print, use the show function to convert the value to a -- string first. -- -- main = appendFile "squares" (show [(x,x*x) | x <- [0,0.1..2]]) -- appendFile :: FilePath -> String -> IO () -- | Wraps: System.IO.hFileSize. hFileSize :: Handle ioMode -> IO Integer -- | Wraps: System.IO.hSetFileSize. hSetFileSize :: Handle ioMode -> Integer -> IO () -- | Wraps: System.IO.hIsEOF. hIsEOF :: (ReadModes ioMode) => Handle ioMode -> IO Bool -- | The computation isEOF is identical to hIsEOF, except -- that it works only on stdin. isEOF :: IO Bool -- | Three kinds of buffering are supported: line-buffering, -- block-buffering or no-buffering. These modes have the following -- effects. For output, items are written out, or flushed, from -- the internal buffer according to the buffer mode: -- -- -- -- An implementation is free to flush the buffer more frequently, but not -- less frequently, than specified above. The output buffer is emptied as -- soon as it has been written out. -- -- Similarly, input occurs according to the buffer mode for the handle: -- -- -- -- The default buffering mode when a handle is opened is -- implementation-dependent and may depend on the file system object -- which is attached to that handle. For most implementations, physical -- files will normally be block-buffered and terminals will normally be -- line-buffered. data BufferMode :: * -- | buffering is disabled if possible. NoBuffering :: BufferMode -- | line-buffering should be enabled if possible. LineBuffering :: BufferMode -- | block-buffering should be enabled if possible. The size of the buffer -- is n items if the argument is Just n and is -- otherwise implementation-dependent. BlockBuffering :: Maybe Int -> BufferMode -- | Wraps: System.IO.hSetBuffering. hSetBuffering :: Handle ioMode -> BufferMode -> IO () -- | Wraps: System.IO.hGetBuffering. hGetBuffering :: Handle ioMode -> IO BufferMode -- | Wraps: System.IO.hFlush. hFlush :: Handle ioMode -> IO () -- | Wraps: System.IO.hGetPosn. hGetPosn :: Handle ioMode -> IO HandlePosn -- | If a call to hGetPosn hdl returns a position -- p, then computation hSetPosn p sets the -- position of hdl to the position it held at the time of the -- call to hGetPosn. -- -- This operation may fail with: -- -- hSetPosn :: HandlePosn -> IO () data HandlePosn :: * -- | Wraps: System.IO.hSeek. hSeek :: Handle ioMode -> SeekMode -> Integer -> IO () -- | A mode that determines the effect of hSeek hdl mode i, as -- follows: data SeekMode :: * -- | the position of hdl is set to i. AbsoluteSeek :: SeekMode -- | the position of hdl is set to offset i from the -- current position. RelativeSeek :: SeekMode -- | the position of hdl is set to offset i from the end -- of the file. SeekFromEnd :: SeekMode -- | Wraps: System.IO.hTell. hTell :: Handle ioMode -> IO Integer -- | Wraps: System.IO.hIsOpen. hIsOpen :: Handle ioMode -> IO Bool -- | Wraps: System.IO.hIsClosed. hIsClosed :: Handle ioMode -> IO Bool -- | Wraps: System.IO.hIsReadable. hIsReadable :: Handle ioMode -> IO Bool -- | Wraps: System.IO.hIsWritable. hIsWritable :: Handle ioMode -> IO Bool -- | Wraps: System.IO.hIsSeekable. hIsSeekable :: Handle ioMode -> IO Bool -- | Wraps: System.IO.hIsTerminalDevice. hIsTerminalDevice :: Handle ioMode -> IO Bool -- | Wraps: System.IO.hSetEcho. hSetEcho :: Handle ioMode -> Bool -> IO () -- | Wraps: System.IO.hGetEcho. hGetEcho :: Handle ioMode -> IO Bool -- | Wraps: System.IO.hShow. hShow :: Handle ioMode -> IO String -- | Wraps: System.IO.hWaitForInput. hWaitForInput :: (ReadModes ioMode) => Handle ioMode -> Int -> IO Bool -- | Wraps: System.IO.hReady. hReady :: (ReadModes ioMode) => Handle ioMode -> IO Bool -- | Wraps: System.IO.hGetChar. hGetChar :: (ReadModes ioMode) => Handle ioMode -> IO Char -- | Wraps: System.IO.hGetLine. hGetLine :: (ReadModes ioMode) => Handle ioMode -> IO String -- | Wraps: System.IO.hLookAhead. hLookAhead :: (ReadModes ioMode) => Handle ioMode -> IO Char -- | Wraps: System.IO.hGetContents. hGetContents :: (ReadModes ioMode) => Handle ioMode -> IO String -- | Wraps: System.IO.hPutChar. hPutChar :: (WriteModes ioMode) => Handle ioMode -> Char -> IO () -- | Wraps: System.IO.hPutStr. hPutStr :: (WriteModes ioMode) => Handle ioMode -> String -> IO () -- | Wraps: System.IO.hPutStrLn. hPutStrLn :: (WriteModes ioMode) => Handle ioMode -> String -> IO () -- | Wraps: System.IO.hPrint. hPrint :: (WriteModes ioMode, Show α) => Handle ioMode -> α -> IO () -- | The interact function takes a function of type -- String->String as its argument. The entire input from the -- standard input device is passed to this function as its argument, and -- the resulting string is output on the standard output device. interact :: (String -> String) -> IO () -- | Write a character to the standard output device (same as -- hPutChar stdout). putChar :: Char -> IO () -- | Write a string to the standard output device (same as hPutStr -- stdout). putStr :: String -> IO () -- | The same as putStr, but adds a newline character. putStrLn :: String -> IO () -- | The print function outputs a value of any printable type to the -- standard output device. Printable types are those that are instances -- of class Show; print converts values to strings for -- output using the show operation and adds a newline. -- -- For example, a program to print the first 20 integers and their powers -- of 2 could be written as: -- -- main = print ([(n, 2^n) | n <- [0..19]]) print :: (Show a) => a -> IO () -- | Read a character from the standard input device (same as -- hGetChar stdin). getChar :: IO Char -- | Read a line from the standard input device (same as hGetLine -- stdin). getLine :: IO String -- | The getContents operation returns all user input as a single -- string, which is read lazily as it is needed (same as -- hGetContents stdin). getContents :: IO String -- | The readIO function is similar to read except that it -- signals parse failure to the IO monad instead of terminating -- the program. readIO :: (Read a) => String -> IO a -- | The readLn function combines getLine and readIO. readLn :: (Read a) => IO a -- | Wraps: System.IO.withBinaryFile. withBinaryFile :: FilePath -> IOMode ioMode -> (Handle ioMode -> IO r) -> IO r -- | Wraps: System.IO.openBinaryFile. openBinaryFile :: FilePath -> IOMode ioMode -> IO (Handle ioMode) -- | Wraps: System.IO.hSetBinaryMode. hSetBinaryMode :: Handle ioMode -> Bool -> IO () -- | Wraps: System.IO.hPutBuf. hPutBuf :: (WriteModes ioMode) => Handle ioMode -> Ptr α -> Int -> IO () -- | Wraps: System.IO.hGetBuf. hGetBuf :: (ReadModes ioMode) => Handle ioMode -> Ptr α -> Int -> IO Int -- | Wraps: System.IO.hPutBufNonBlocking. hPutBufNonBlocking :: (WriteModes ioMode) => Handle ioMode -> Ptr α -> Int -> IO Int -- | Wraps: System.IO.hGetBufNonBlocking. hGetBufNonBlocking :: (ReadModes ioMode) => Handle ioMode -> Ptr α -> Int -> IO Int -- | Wraps: System.IO.openTempFile. openTempFile :: FilePath -> String -> IO (FilePath, Handle RW) -- | Wraps: System.IO.openBinaryTempFile. openBinaryTempFile :: FilePath -> String -> IO (FilePath, Handle RW) openTempFileWithDefaultPermissions :: FilePath -> String -> IO (FilePath, Handle RW) openBinaryTempFileWithDefaultPermissions :: FilePath -> String -> IO (FilePath, Handle RW) hSetEncoding :: Handle ioMode -> TextEncoding -> IO () hGetEncoding :: Handle ioMode -> IO (Maybe TextEncoding) -- | A TextEncoding is a specification of a conversion scheme -- between sequences of bytes and sequences of Unicode characters. -- -- For example, UTF-8 is an encoding of Unicode characters into a -- sequence of bytes. The TextEncoding for UTF-8 is utf8. data TextEncoding :: * -- | The Latin1 (ISO8859-1) encoding. This encoding maps bytes directly to -- the first 256 Unicode code points, and is thus not a complete Unicode -- encoding. An attempt to write a character greater than '\255' to a -- Handle using the latin1 encoding will result in an error. latin1 :: TextEncoding -- | The UTF-8 Unicode encoding utf8 :: TextEncoding -- | The UTF-8 Unicode encoding, with a byte-order-mark (BOM; the byte -- sequence 0xEF 0xBB 0xBF). This encoding behaves like utf8, -- except that on input, the BOM sequence is ignored at the beginning of -- the stream, and on output, the BOM sequence is prepended. -- -- The byte-order-mark is strictly unnecessary in UTF-8, but is sometimes -- used to identify the encoding of a file. utf8_bom :: TextEncoding -- | The UTF-16 Unicode encoding (a byte-order-mark should be used to -- indicate endianness). utf16 :: TextEncoding -- | The UTF-16 Unicode encoding (litte-endian) utf16le :: TextEncoding -- | The UTF-16 Unicode encoding (big-endian) utf16be :: TextEncoding -- | The UTF-32 Unicode encoding (a byte-order-mark should be used to -- indicate endianness). utf32 :: TextEncoding -- | The UTF-32 Unicode encoding (litte-endian) utf32le :: TextEncoding -- | The UTF-32 Unicode encoding (big-endian) utf32be :: TextEncoding -- | The Unicode encoding of the current locale localeEncoding :: TextEncoding -- | Look up the named Unicode encoding. May fail with -- -- -- -- The set of known encodings is system-dependent, but includes at least: -- -- -- -- On systems using GNU iconv (e.g. Linux), there is additional notation -- for specifying how illegal characters are handled: -- -- -- -- On Windows, you can access supported code pages with the prefix -- CP; for example, "CP1250". mkTextEncoding :: String -> IO TextEncoding hSetNewlineMode :: Handle ioMode -> NewlineMode -> IO () -- | The representation of a newline in the external file or stream. data Newline :: * -- | '\n' LF :: Newline -- | '\r\n' CRLF :: Newline -- | The native newline representation for the current platform: LF -- on Unix systems, CRLF on Windows. nativeNewline :: Newline -- | Specifies the translation, if any, of newline characters between -- internal Strings and the external file or stream. Haskell Strings are -- assumed to represent newlines with the '\n' character; the newline -- mode specifies how to translate '\n' on output, and what to translate -- into '\n' on input. data NewlineMode :: * NewlineMode :: Newline -> Newline -> NewlineMode -- | the representation of newlines on input inputNL :: NewlineMode -> Newline -- | the representation of newlines on output outputNL :: NewlineMode -> Newline -- | Do no newline translation at all. -- -- noNewlineTranslation = NewlineMode { inputNL = LF, outputNL = LF -- } noNewlineTranslation :: NewlineMode -- | Map '\r\n' into '\n' on input, and '\n' to the native newline -- represetnation on output. This mode can be used on any platform, and -- works with text files using any newline convention. The downside is -- that readFile >>= writeFile might yield a different -- file. -- -- universalNewlineMode = NewlineMode { inputNL = CRLF, outputNL = -- nativeNewline } universalNewlineMode :: NewlineMode -- | Use the native newline representation on both input and output -- -- nativeNewlineMode = NewlineMode { inputNL = nativeNewline -- outputNL = nativeNewline } nativeNewlineMode :: NewlineMode instance Show (IOMode ioMode) instance Ord (IOMode ioMode) instance Eq (IOMode ioMode) instance CheckMode RW instance CheckMode A instance CheckMode W instance CheckMode R instance WriteModes RW instance WriteModes A instance WriteModes W instance ReadModes RW instance ReadModes R -- | This module lifts the bytestring IO operations to handles with -- explicit IOModes. module Data.ByteString.ExplicitIOModes -- | Wraps Data.ByteString.hGetLine. hGetLine :: (ReadModes ioMode) => Handle ioMode -> IO ByteString -- | Wraps Data.ByteString.hGetContents. hGetContents :: (ReadModes ioMode) => Handle ioMode -> IO ByteString -- | Wraps Data.ByteString.hGet. hGet :: (ReadModes ioMode) => Handle ioMode -> Int -> IO ByteString -- | Wraps Data.ByteString.hGetNonBlocking. hGetNonBlocking :: (ReadModes ioMode) => Handle ioMode -> Int -> IO ByteString -- | Wraps Data.ByteString.hPut. hPut :: (WriteModes ioMode) => Handle ioMode -> ByteString -> IO () -- | Wraps Data.ByteString.hPutStr. hPutStr :: (WriteModes ioMode) => Handle ioMode -> ByteString -> IO () -- | Wraps Data.ByteString.hPutStrLn. hPutStrLn :: (WriteModes ioMode) => Handle ioMode -> ByteString -> IO () -- | This module lifts the bytestring IO operations to handles with -- explicit IOModes. module Data.ByteString.Char8.ExplicitIOModes -- | Wraps Data.ByteString.hGetLine. hGetLine :: (ReadModes ioMode) => Handle ioMode -> IO ByteString -- | Wraps Data.ByteString.hGetContents. hGetContents :: (ReadModes ioMode) => Handle ioMode -> IO ByteString -- | Wraps Data.ByteString.hGet. hGet :: (ReadModes ioMode) => Handle ioMode -> Int -> IO ByteString -- | Wraps Data.ByteString.hGetNonBlocking. hGetNonBlocking :: (ReadModes ioMode) => Handle ioMode -> Int -> IO ByteString -- | Wraps Data.ByteString.hPut. hPut :: (WriteModes ioMode) => Handle ioMode -> ByteString -> IO () -- | Wraps Data.ByteString.hPutStr. hPutStr :: (WriteModes ioMode) => Handle ioMode -> ByteString -> IO () -- | Wraps Data.ByteString.hPutStrLn. hPutStrLn :: (WriteModes ioMode) => Handle ioMode -> ByteString -> IO () -- | This module lifts the bytestring IO operations to handles with -- explicit IOModes. module Data.ByteString.Lazy.ExplicitIOModes -- | Wraps Data.ByteString.hGetContents. hGetContents :: (ReadModes ioMode) => Handle ioMode -> IO ByteString -- | Wraps Data.ByteString.hGet. hGet :: (ReadModes ioMode) => Handle ioMode -> Int -> IO ByteString -- | Wraps Data.ByteString.hGetNonBlocking. hGetNonBlocking :: (ReadModes ioMode) => Handle ioMode -> Int -> IO ByteString -- | Wraps Data.ByteString.hPut. hPut :: (WriteModes ioMode) => Handle ioMode -> ByteString -> IO () -- | Wraps Data.ByteString.hPutStr. hPutStr :: (WriteModes ioMode) => Handle ioMode -> ByteString -> IO () -- | This module lifts the bytestring IO operations to handles with -- explicit IOModes. module Data.ByteString.Lazy.Char8.ExplicitIOModes -- | Wraps Data.ByteString.hGetContents. hGetContents :: (ReadModes ioMode) => Handle ioMode -> IO ByteString -- | Wraps Data.ByteString.hGet. hGet :: (ReadModes ioMode) => Handle ioMode -> Int -> IO ByteString -- | Wraps Data.ByteString.hGetNonBlocking. hGetNonBlocking :: (ReadModes ioMode) => Handle ioMode -> Int -> IO ByteString -- | Wraps Data.ByteString.hPut. hPut :: (WriteModes ioMode) => Handle ioMode -> ByteString -> IO ()