-- 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. -- -- See the explicit-iomodes-bytestring/text package for -- ByteString/Text operations. @package explicit-iomodes @version 0.6 module System.IO.ExplicitIOModes.Unsafe -- | Retrieves the regular System.IO.Handle. regularHandle :: Handle ioMode -> Handle wrap :: (Handle -> α) -> (Handle ioMode -> α) wrap2 :: (Handle -> β -> α) -> (Handle ioMode -> β -> α) -- | 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 (ReadMode for stdin -- and WriteMode 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 ReadMode -- | Write only. data WriteMode -- | Write only by appending. data AppendMode -- | Both read and write. data ReadWriteMode -- | Class of readable IO mode types. -- -- Note the super class ReadModesPrivate. This type class is not -- exported by this module which ensures you can't accidentally make -- another type (like WriteMode or AppendMode) an instance -- of ReadModes. class ReadModesPrivate ioMode => ReadModes ioMode -- | Class of writable IO mode types. -- -- Note the super class WriteModesPrivate. This type class is -- not exported by this module which ensures you can't accidentally make -- another type (like ReadMode) an instance of WriteModes. class WriteModesPrivate ioMode => WriteModes ioMode -- | The IOMode GADT which for each constructor specifies the associated -- IOMode type. -- -- Also see: System.IO.IOMode. data IOMode ioMode ReadMode :: IOMode ReadMode WriteMode :: IOMode WriteMode AppendMode :: IOMode AppendMode ReadWriteMode :: IOMode ReadWriteMode class MkIOMode ioMode mkIOMode :: MkIOMode ioMode => IOMode ioMode -- | Retrieves the regular System.IO.IOMode. regularIOMode :: IOMode ioMode -> IOMode -- | Wraps: System.IO.stdin. stdin :: Handle ReadMode -- | Wraps: System.IO.stdout. stdout :: Handle WriteMode -- | Wraps: System.IO.stderr. stderr :: Handle WriteMode -- | 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.openFile. openFile :: FilePath -> IOMode ioMode -> IO (Handle ioMode) -- | Wraps: System.IO.withFile. withFile :: FilePath -> IOMode ioMode -> (Handle ioMode -> IO α) -> IO α -- | Open a file without explicitly specifying the IOMode. The IOMode is -- inferred from the type of the resulting Handle. -- -- Note that: openFile' fp = openFile fp mkIOMode. openFile' :: MkIOMode ioMode => FilePath -> IO (Handle ioMode) -- | Note that: withFile' fp = withFile fp mkIOMode. withFile' :: MkIOMode ioMode => FilePath -> (Handle ioMode -> IO α) -> IO α -- | 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: -- --
-- 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.openBinaryFile. openBinaryFile :: FilePath -> IOMode ioMode -> IO (Handle ioMode) -- | Wraps: System.IO.withBinaryFile. withBinaryFile :: FilePath -> IOMode ioMode -> (Handle ioMode -> IO α) -> IO α -- | Note that: openBinaryFile' fp = openBinaryFile fp -- mkIOMode. openBinaryFile' :: MkIOMode ioMode => FilePath -> IO (Handle ioMode) -- | Note that: withBinaryFile' fp = withBinaryFile fp -- mkIOMode. withBinaryFile' :: MkIOMode ioMode => FilePath -> (Handle ioMode -> IO α) -> IO α -- | 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.hGetBufSome. hGetBufSome :: 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 ReadWriteMode) -- | Wraps: System.IO.openBinaryTempFile. openBinaryTempFile :: FilePath -> String -> IO (FilePath, Handle ReadWriteMode) openTempFileWithDefaultPermissions :: FilePath -> String -> IO (FilePath, Handle ReadWriteMode) openBinaryTempFileWithDefaultPermissions :: FilePath -> String -> IO (FilePath, Handle ReadWriteMode) 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 -- --
UTF-8
-- 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 CheckMode ReadWriteMode
instance CheckMode AppendMode
instance CheckMode WriteMode
instance CheckMode ReadMode
instance Show (IOMode ioMode)
instance Eq (IOMode ioMode)
instance MkIOMode ReadWriteMode
instance MkIOMode AppendMode
instance MkIOMode WriteMode
instance MkIOMode ReadMode
instance WriteModes ReadWriteMode
instance WriteModesPrivate ReadWriteMode
instance WriteModes AppendMode
instance WriteModesPrivate AppendMode
instance WriteModes WriteMode
instance WriteModesPrivate WriteMode
instance ReadModes ReadWriteMode
instance ReadModesPrivate ReadWriteMode
instance ReadModes ReadMode
instance ReadModesPrivate ReadMode