foundation-0.0.30: Alternative prelude with batteries and no dependencies
LicenseBSD-style
MaintainerVincent Hanquez <vincent@snarc.org>
Stabilityexperimental
Portabilityportable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Foundation.IO

Contents

Description

IO Routine

Synopsis

Terminal

putStrLn :: String -> IO () Source #

Print a string with a newline to standard output

putStr :: String -> IO () Source #

Print a string to standard output

File

data IOMode #

Instances

Instances details
Enum IOMode

Since: base-4.2.0.0

Instance details

Defined in GHC.IO.IOMode

Ix IOMode

Since: base-4.2.0.0

Instance details

Defined in GHC.IO.IOMode

Read IOMode

Since: base-4.2.0.0

Instance details

Defined in GHC.IO.IOMode

Show IOMode

Since: base-4.2.0.0

Instance details

Defined in GHC.IO.IOMode

Eq IOMode

Since: base-4.2.0.0

Instance details

Defined in GHC.IO.IOMode

Methods

(==) :: IOMode -> IOMode -> Bool #

(/=) :: IOMode -> IOMode -> Bool #

Ord IOMode

Since: base-4.2.0.0

Instance details

Defined in GHC.IO.IOMode

openFile :: FilePath -> IOMode -> IO Handle Source #

list the file name in the given FilePath directory

TODO: error management and not implemented yet getDirectory :: FilePath -> IO [FileName] getDirectory = undefined

Open a new handle on the file

closeFile :: Handle -> IO () Source #

Close a handle

withFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r Source #

withFile filepath mode act opens a file using the mode and run act. the by-product handle will be closed when act finish, either normally or through an exception.

The value returned is the result of act@

hGet :: Handle -> Int -> IO (UArray Word8) Source #

Read binary data directly from the specified Handle.

First argument is the Handle to read from, and the second is the number of bytes to read. It returns the bytes read, up to the specified size, or an empty array if EOF has been reached.

hGet is implemented in terms of hGetBuf.

readFile :: FilePath -> IO (UArray Word8) Source #

Read a binary file and return the whole content in one contiguous buffer.