System.Directory.Internal.Prelude

directory-1.3.3.2: Platform-agnostic library for filesystem operations

Stability | unstable
Portability | portable
Safe Haskell | Safe
Language | Haskell2010

System.Directory.Internal.Prelude

Description

Internal modules are always subject to change from version to version.

Synopsis

- module Prelude
- second :: Arrow a => a b c -> a (d, b) (d, c)
- killThread :: ThreadId -> IO ()
- forkIO :: IO () -> IO ThreadId
- putMVar :: MVar a -> a -> IO ()
- readMVar :: MVar a -> IO a
- takeMVar :: MVar a -> IO a
- newEmptyMVar :: IO (MVar a)
- bracket_ :: IO a -> IO b -> IO c -> IO c
- finally :: IO a -> IO b -> IO a
- bracket :: IO a -> (a -> IO b) -> (a -> IO c) -> IO c
- onException :: IO a -> IO b -> IO a
- try :: Exception e => IO a -> IO (Either e a)
- mask :: ((forall a. IO a -> IO a) -> IO b) -> IO b
- throwIO :: Exception e => e -> IO a
- catch :: Exception e => IO a -> (e -> IO a) -> IO a
- data SomeException
- unless :: Applicative f => Bool -> f () -> f ()
- replicateM_ :: Applicative m => Int -> m a -> m ()
- (<=<) :: Monad m => (b -> m c) -> (a -> m b) -> a -> m c
- (>=>) :: Monad m => (a -> m b) -> (b -> m c) -> a -> m c
- when :: Applicative f => Bool -> f () -> f ()
- (.&.) :: Bits a => a -> a -> a
- (.|.) :: Bits a => a -> a -> a
- complement :: Bits a => a -> a
- toUpper :: Char -> Char
- toLower :: Char -> Char
- isAlpha :: Char -> Bool
- isAscii :: Char -> Bool
- for_ :: (Foldable t, Applicative f) => t a -> (a -> f b) -> f ()
- traverse_ :: (Foldable t, Applicative f) => (a -> f b) -> t a -> f ()
- on :: (b -> b -> c) -> (a -> b) -> a -> a -> c
- catMaybes :: [Maybe a] -> [a]
- maybeToList :: Maybe a -> [a]
- fromMaybe :: a -> Maybe a -> a
- (<>) :: Semigroup a => a -> a -> a
- mempty :: Monoid a => a
- mconcat :: Monoid a => [a] -> a
- writeIORef :: IORef a -> a -> IO ()
- readIORef :: IORef a -> IO a
- newIORef :: a -> IO (IORef a)
- data IORef a
- for :: (Traversable t, Applicative f) => t a -> (a -> f b) -> f (t b)
- data Ptr a
- withArray :: Storable a => [a] -> (Ptr a -> IO b) -> IO b
- allocaArray :: Storable a => Int -> (Ptr a -> IO b) -> IO b
- maybeWith :: (a -> (Ptr b -> IO c) -> IO c) -> Maybe a -> (Ptr b -> IO c) -> IO c
- with :: Storable a => a -> (Ptr a -> IO b) -> IO b
- allocaBytesAligned :: Int -> Int -> (Ptr a -> IO b) -> IO b
- allocaBytes :: Int -> (Ptr a -> IO b) -> IO b
- alloca :: Storable a => (Ptr a -> IO b) -> IO b
- class Storable a where
  - sizeOf :: a -> Int
  - alignment :: a -> Int
  - peekElemOff :: Ptr a -> Int -> IO a
  - pokeElemOff :: Ptr a -> Int -> a -> IO ()
  - peekByteOff :: Ptr b -> Int -> IO a
  - pokeByteOff :: Ptr b -> Int -> a -> IO ()
  - peek :: Ptr a -> IO a
  - poke :: Ptr a -> a -> IO ()
- plusPtr :: Ptr a -> Int -> Ptr b
- nullPtr :: Ptr a
- throwErrnoPathIfMinus1_ :: (Eq a, Num a) => String -> FilePath -> IO a -> IO ()
- throwErrnoIfNull :: String -> IO (Ptr a) -> IO (Ptr a)
- throwErrnoIfMinus1Retry_ :: (Eq a, Num a) => String -> IO a -> IO ()
- throwErrnoIfMinus1_ :: (Eq a, Num a) => String -> IO a -> IO ()
- withCWString :: String -> (CWString -> IO a) -> IO a
- peekCWStringLen :: CWStringLen -> IO String
- withCString :: String -> (CString -> IO a) -> IO a
- peekCString :: CString -> IO String
- type CString = Ptr CChar
- type CWString = Ptr CWchar
- newtype CUChar = CUChar Word8
- newtype CUShort = CUShort Word16
- newtype CInt = CInt Int32
- newtype CLong = CLong Int64
- newtype CULong = CULong Word64
- newtype CWchar = CWchar Int32
- newtype CTime = CTime Int64
- getFileSystemEncoding :: IO TextEncoding
- data IOErrorType
  - = OtherError
  - | InappropriateType
  - | UnsupportedOperation
- lookupEnv :: String -> IO (Maybe String)
- getEnv :: String -> IO String
- getArgs :: IO [String]
- exitFailure :: IO a
- openBinaryTempFile :: FilePath -> String -> IO (FilePath, Handle)
- withBinaryFile :: FilePath -> IOMode -> (Handle -> IO r) -> IO r
- hClose :: Handle -> IO ()
- stderr :: Handle
- hGetBuf :: Handle -> Ptr a -> Int -> IO Int
- hPutBuf :: Handle -> Ptr a -> Int -> IO ()
- hPutStrLn :: Handle -> String -> IO ()
- hPutStr :: Handle -> String -> IO ()
- hFlush :: Handle -> IO ()
- stdout :: Handle
- data Handle
- data IOMode
  - = ReadMode
  - | WriteMode
- catchIOError :: IO a -> (IOError -> IO a) -> IO a
- modifyIOError :: (IOError -> IOError) -> IO a -> IO a
- ioeSetFileName :: IOError -> FilePath -> IOError
- ioeSetLocation :: IOError -> String -> IOError
- ioeSetErrorString :: IOError -> String -> IOError
- ioeGetLocation :: IOError -> String
- ioeGetErrorString :: IOError -> String
- ioeGetErrorType :: IOError -> IOErrorType
- permissionErrorType :: IOErrorType
- illegalOperationErrorType :: IOErrorType
- isPermissionError :: IOError -> Bool
- isIllegalOperation :: IOError -> Bool
- isDoesNotExistError :: IOError -> Bool
- isAlreadyExistsError :: IOError -> Bool
- mkIOError :: IOErrorType -> String -> Maybe Handle -> Maybe FilePath -> IOError
- tryIOError :: IO a -> IO (Either IOError a)
- userError :: String -> IOError
- type IOError = IOException
- withFilePath :: FilePath -> (CString -> IO a) -> IO a
- type EpochTime = CTime
- timeout :: Int -> IO a -> IO (Maybe a)
- data Void

# Documentation

module Prelude

second :: Arrow a => a b c -> a (d, b) (d, c) Source #

A mirror image of `first`.

The default definition may be overridden with a more efficient version if desired.

killThread :: ThreadId -> IO () Source #

`killThread` raises the `ThreadKilled` exception in the given thread (GHC only).

    killThread tid = throwTo tid ThreadKilled

forkIO :: IO () -> IO ThreadId Source #

Creates a new thread to run the `IO` computation passed as the first argument, and returns the `ThreadId` of the newly created thread.

The new thread will be a lightweight, unbound thread. Foreign calls made by this thread are not guaranteed to be made by any particular OS thread; if you need foreign calls to be made by a particular OS thread, then use `forkOS` instead.

The new thread inherits the masked state of the parent (see `mask`).

The newly created thread has an exception handler that discards the exceptions `BlockedIndefinitelyOnMVar`, `BlockedIndefinitelyOnSTM`, and `ThreadKilled`, and passes all other exceptions to the uncaught exception handler.

putMVar :: MVar a -> a -> IO () Source #

Put a value into an `MVar`. If the `MVar` is currently full, `putMVar` will wait until it becomes empty.

There are two further important properties of `putMVar`:

- `putMVar` is single-wakeup. That is, if there are multiple threads blocked in `putMVar`, and the `MVar` becomes empty, only one thread will be woken up. The runtime guarantees that the woken thread completes its `putMVar` operation.
- When multiple threads are blocked on an `MVar`, they are woken up in FIFO order. This is useful for providing fairness properties of abstractions built using `MVar`s.

readMVar :: MVar a -> IO a Source #

Atomically read the contents of an `MVar`. If the `MVar` is currently empty, `readMVar` will wait until it is full. `readMVar` is guaranteed to receive the next `putMVar`.

`readMVar` is multiple-wakeup, so when multiple readers are blocked on an `MVar`, all of them are woken up at the same time.

Compatibility note: Prior to base 4.7, `readMVar` was a combination of `takeMVar` and `putMVar`. This mean that in the presence of other threads attempting to `putMVar`, `readMVar` could block. Furthermore, `readMVar` would not receive the next `putMVar` if there was already a pending thread blocked on `takeMVar`. The old behavior can be recovered by implementing 'readMVar as follows:

     readMVar :: MVar a -> IO a
     readMVar m =
       mask_ $ do
         a <- takeMVar m
         putMVar m a
         return a

takeMVar :: MVar a -> IO a Source #

Return the contents of the `MVar`. If the `MVar` is currently empty, `takeMVar` will wait until it is full. After a `takeMVar`, the `MVar` is left empty.

There are two further important properties of `takeMVar`:

- `takeMVar` is single-wakeup. That is, if there are multiple threads blocked in `takeMVar`, and the `MVar` becomes full, only one thread will be woken up. The runtime guarantees that the woken thread completes its `takeMVar` operation.
- When multiple threads are blocked on an `MVar`, they are woken up in FIFO order. This is useful for providing fairness properties of abstractions built using `MVar`s.

newEmptyMVar :: IO (MVar a) Source #

Create an `MVar` which is initially empty.

bracket_ :: IO a -> IO b -> IO c -> IO c Source #

A variant of `bracket` where the return value from the first computation is not required.

finally Source #

Arguments

:: IO a | computation to run first
-> IO b | computation to run afterward (even if an exception was raised)
-> IO a |

A specialised variant of `bracket` with just a computation to run afterward.

bracket Source #

Arguments

:: IO a | computation to run first ("acquire resource")
-> (a -> IO b) | computation to run last ("release resource")
-> (a -> IO c) | computation to run in-between
-> IO c |

When you want to acquire a resource, do some work with it, and then release the resource, it is a good idea to use `bracket`, because `bracket` will install the necessary exception handler to release the resource in the event that an exception is raised during the computation. If an exception is raised, then `bracket` will re-raise the exception (after performing the release).

A common example is opening a file:

    bracket
      (openFile "filename" ReadMode)
      (hClose)
      (\fileHandle -> do { ... })

The arguments to `bracket` are in this order so that we can partially apply it, e.g.:

    withFile name mode = bracket (openFile name mode) hClose

onException :: IO a -> IO b -> IO a Source #

Like `finally`, but only performs the final action if there was an exception raised by the computation.

try :: Exception e => IO a -> IO (Either e a) Source #

Similar to `catch`, but returns an `Either` result which is `(`Right` a)` if no exception of type `e` was raised, or `(`Left` ex)` if an exception of type `e` was raised and its value is `ex`. If any other type of exception is raised than it will be propogated up to the next enclosing exception handler.

     try a = catch (Right `liftM` a) (return . Left)

mask :: ((forall a. IO a -> IO a) -> IO b) -> IO b Source #

Executes an IO computation with asynchronous exceptions masked. That is, any thread which attempts to raise an exception in the current thread with `throwTo` will be blocked until asynchronous exceptions are unmasked again.

The argument passed to `mask` is a function that takes as its argument another function, which can be used to restore the prevailing masking state within the context of the masked computation. For example, a common way to use `mask` is to protect the acquisition of a resource:

    mask $ \restore -> do
        x <- acquire
        restore (do_something_with x) `onException` release
        release

This code guarantees that `acquire` is paired with `release`, by masking asynchronous exceptions for the critical parts. (Rather than write this code yourself, it would be better to use `bracket` which abstracts the general pattern).

Note that the `restore` action passed to the argument to `mask` does not necessarily unmask asynchronous exceptions, it just restores the masking state to that of the enclosing context. Thus if asynchronous exceptions are already masked, `mask` cannot be used to unmask exceptions again. This is so that if you call a library function with exceptions masked, you can be sure that the library call will not be able to unmask exceptions again. If you are writing library code and need to use asynchronous exceptions, the only way is to create a new thread; see `forkIOWithUnmask`.

Asynchronous exceptions may still be received while in the masked state if the masked thread blocks in certain ways; see Control.Exception.

Threads created by `forkIO` inherit the `MaskingState` from the parent; that is, to start a thread in the `MaskedInterruptible` state, use `mask_ $ forkIO ...`. This is particularly useful if you need to establish an exception handler in the forked thread before any asynchronous exceptions are received. To create a new thread in an unmasked state use `forkIOWithUnmask`.

throwIO :: Exception e => e -> IO a Source #

A variant of `throw` that can only be used within the `IO` monad.

Although `throwIO` has a type that is an instance of the type of `throw`, the two functions are subtly different:

    throw e   `seq` x  ===> throw e
    throwIO e `seq` x  ===> x

The first example will cause the exception `e` to be raised, whereas the second one won't. In fact, `throwIO` will only cause an exception to be raised when it is used within the `IO` monad. The `throwIO` variant should be used in preference to `throw` to raise an exception within the `IO` monad because it guarantees ordering with respect to other `IO` operations, whereas `throw` does not.

catch Source #

Arguments

:: Exception e |
=> IO a | The computation to run
-> (e -> IO a) | Handler to invoke if an exception is raised
-> IO a |

This is the simplest of the exception-catching functions. It takes a single argument, runs it, and if an exception is raised the "handler" is executed, with the value of the exception passed as an argument. Otherwise, the result is returned as normal. For example:

      catch (readFile f)
            (\e -> do let err = show (e :: IOException)
                      hPutStr stderr ("Warning: Couldn't open " ++ f ++ ": " ++ err)
                      return "")

Note that we have to give a type signature to `e`, or the program will not typecheck as the type is ambiguous. While it is possible to catch exceptions of any type, see the section "Catching all exceptions" (in Control.Exception) for an explanation of the problems with doing so.

For catching exceptions in pure (non-`IO`) expressions, see the function `evaluate`.

Note that due to Haskell's unspecified evaluation order, an expression may throw one of several possible exceptions: consider the expression `(error "urk") + (1 `div` 0)`. Does the expression throw `ErrorCall "urk"`, or `DivideByZero`?

The answer is "it might throw either"; the choice is non-deterministic. If you are catching any type of exception then you might catch either. If you are calling `catch` with type `IO Int -> (ArithException -> IO Int) -> IO Int` then the handler may get run with `DivideByZero` as an argument, or an `ErrorCall "urk"` exception may be propogated further up. If you call it again, you might get a the opposite behaviour. This is ok, because `catch` is an `IO` computation.

data SomeException Source #

The `SomeException` type is the root of the exception type hierarchy. When an exception of type `e` is thrown, behind the scenes it is encapsulated in a `SomeException`.

#### Instances

Instances details

Show SomeException | Since: base-3.0
Instance details Defined in GHC.Exception.Type Methods showsPrec :: Int -> SomeException -> ShowS Source # show :: SomeException -> String Source # showList :: [SomeException] -> ShowS Source #
Exception SomeException | Since: base-3.0
Instance details Defined in GHC.Exception.Type Methods toException :: SomeException -> SomeException Source # fromException :: SomeException -> Maybe SomeException Source # displayException :: SomeException -> String Source #

unless :: Applicative f => Bool -> f () -> f () Source #

The reverse of `when`.

replicateM_ :: Applicative m => Int -> m a -> m () Source #

Like `replicateM`, but discards the result.

(<=<) :: Monad m => (b -> m c) -> (a -> m b) -> a -> m c infixr 1 Source #

Right-to-left composition of Kleisli arrows. `(`>=>`)`, with the arguments flipped.

Note how this operator resembles function composition `(`.`)`:

    (.)   ::            (b ->   c) -> (a ->   b) -> a ->   c
    (<=<) :: Monad m => (b -> m c) -> (a -> m b) -> a -> m c

(>=>) :: Monad m => (a -> m b) -> (b -> m c) -> a -> m c infixr 1 Source #

Left-to-right composition of Kleisli arrows.

when :: Applicative f => Bool -> f () -> f () Source #

Conditional execution of `Applicative` expressions. For example,

    when debug (putStrLn "Debugging")

will output the string `Debugging` if the Boolean value `debug` is `True`, and otherwise do nothing.

(.&.) :: Bits a => a -> a -> a infixl 7 Source #

Bitwise "and"

(.|.) :: Bits a => a -> a -> a infixl 5 Source #

Bitwise "or"

complement :: Bits a => a -> a Source #

Reverse all the bits in the argument

toUpper :: Char -> Char Source #

Convert a letter to the corresponding upper-case letter, if any. Any other character is returned unchanged.

toLower :: Char -> Char Source #

Convert a letter to the corresponding lower-case letter, if any. Any other character is returned unchanged.

isAlpha :: Char -> Bool Source #

Selects alphabetic Unicode characters (lower-case, upper-case and title-case letters, plus letters of caseless scripts and modifiers letters). This function is equivalent to `isLetter`.

isAscii :: Char -> Bool Source #

Selects the first 128 characters of the Unicode character set, corresponding to the ASCII character set.

for_ :: (Foldable t, Applicative f) => t a -> (a -> f b) -> f () Source #

`for_` is `traverse_` with its arguments flipped. For a version that doesn't ignore the results see `for`.

    >>> for_ [1..4] print
    1
    2
    3
    4

traverse_ :: (Foldable t, Applicative f) => (a -> f b) -> t a -> f () Source #

Map each element of a structure to an action, evaluate these actions from left to right, and ignore the results. For a version that doesn't ignore the results see `traverse`.

on :: (b -> b -> c) -> (a -> b) -> a -> a -> c infixl 0 Source #

``on` b u x y` runs the binary function `b` on the results of applying unary function `u` to two arguments `x` and `y`. From the opposite perspective, it transforms two inputs and combines the outputs.

    ((+) `on` f) x y = f x + f y

Typical usage: ``sortBy` (`compare` `on` `fst`)`.

Algebraic properties:

-     (*) `on` id = (*) -- (if (*) ∉ {⊥, const ⊥})

-     ((*) `on` f) `on` g = (*) `on` (f . g)

-     flip on f . flip on g = flip on (g . f)

catMaybes :: [Maybe a] -> [a] Source #

The `catMaybes` function takes a list of `Maybe`s and returns a list of all the `Just` values.

#### Examples

Expand

Basic usage:

    >>> catMaybes [Just 1, Nothing, Just 3]
    [1,3]

When constructing a list of `Maybe` values, `catMaybes` can be used to return all of the "success" results (if the list is the result of a `map`, then `mapMaybe` would be more appropriate):

    >>> import Text.Read ( readMaybe )
    >>> [readMaybe x :: Maybe Int | x <- ["1", "Foo", "3"] ]
    [Just 1,Nothing,Just 3]
    >>> catMaybes $ [readMaybe x :: Maybe Int | x <- ["1", "Foo", "3"] ]
    [1,3]

maybeToList :: Maybe a -> [a] Source #

The `maybeToList` function returns an empty list when given `Nothing` or a singleton list when given `Just`.

#### Examples

Expand

Basic usage:

    >>> maybeToList (Just 7)
    [7]

    >>> maybeToList Nothing
    []

One can use `maybeToList` to avoid pattern matching when combined with a function that (safely) works on lists:

    >>> import Text.Read ( readMaybe )
    >>> sum $ maybeToList (readMaybe "3")
    3
    >>> sum $ maybeToList (readMaybe "")
    0

fromMaybe :: a -> Maybe a -> a Source #

The `fromMaybe` function takes a default value and and `Maybe` value. If the `Maybe` is `Nothing`, it returns the default values; otherwise, it returns the value contained in the `Maybe`.

#### Examples

Expand

Basic usage:

    >>> fromMaybe "" (Just "Hello, World!")
    "Hello, World!"

    >>> fromMaybe "" Nothing
    ""

Read an integer from a string using `readMaybe`. If we fail to parse an integer, we want to return `0` by default:

    >>> import Text.Read ( readMaybe )
    >>> fromMaybe 0 (readMaybe "5")
    5
    >>> fromMaybe 0 (readMaybe "")
    0

(<>) :: Semigroup a => a -> a -> a infixr 6 Source #

An associative operation.

mempty :: Monoid a => a Source #

Identity of `mappend`

mconcat :: Monoid a => [a] -> a Source #

Fold a list using the monoid.

For most types, the default definition for `mconcat` will be used, but the function is included in the class definition so that an optimized version can be provided for specific types.

writeIORef :: IORef a -> a -> IO () Source #

Write a new value into an `IORef`

readIORef :: IORef a -> IO a Source #

Read the value of an `IORef`

newIORef :: a -> IO (IORef a) Source #

Build a new `IORef`

data IORef a Source #

A mutable variable in the `IO` monad

#### Instances

Instances details

Eq (IORef a) | Pointer equality. Since: base-4.0.0.0
Instance details Defined in GHC.IORef Methods (==) :: IORef a -> IORef a -> Bool # (/=) :: IORef a -> IORef a -> Bool #

for :: (Traversable t, Applicative f) => t a -> (a -> f b) -> f (t b) Source #

`for` is `traverse` with its arguments flipped. For a version that ignores the results see `for_`.

data Ptr a Source #

A value of type ``Ptr` a` represents a pointer to an object, or an array of objects, which may be marshalled to or from Haskell values of type `a`.

The type `a` will often be an instance of class `Storable` which provides the marshalling operations. However this is not essential, and you can provide your own operations to access the pointer. For example you might write small foreign functions to get or set the fields of a C `struct`.

#### Instances

Instances details

Eq (Ptr a) | Since: base-2.1
Instance details Defined in GHC.Ptr Methods (==) :: Ptr a -> Ptr a -> Bool # (/=) :: Ptr a -> Ptr a -> Bool #
Ord (Ptr a) | Since: base-2.1
Instance details Defined in GHC.Ptr Methods compare :: Ptr a -> Ptr a -> Ordering # (<) :: Ptr a -> Ptr a -> Bool # (<=) :: Ptr a -> Ptr a -> Bool # (>) :: Ptr a -> Ptr a -> Bool # (>=) :: Ptr a -> Ptr a -> Bool # max :: Ptr a -> Ptr a -> Ptr a # min :: Ptr a -> Ptr a -> Ptr a #
Show (Ptr a) | Since: base-2.1
Instance details Defined in GHC.Ptr Methods showsPrec :: Int -> Ptr a -> ShowS Source # show :: Ptr a -> String Source # showList :: [Ptr a] -> ShowS Source #
Storable (Ptr a) | Since: base-2.1
Instance details Defined in Foreign.Storable Methods sizeOf :: Ptr a -> Int Source # alignment :: Ptr a -> Int Source # peekElemOff :: Ptr (Ptr a) -> Int -> IO (Ptr a) Source # pokeElemOff :: Ptr (Ptr a) -> Int -> Ptr a -> IO () Source # peekByteOff :: Ptr b -> Int -> IO (Ptr a) Source # pokeByteOff :: Ptr b -> Int -> Ptr a -> IO () Source # peek :: Ptr (Ptr a) -> IO (Ptr a) Source # poke :: Ptr (Ptr a) -> Ptr a -> IO () Source #
Foldable (URec (Ptr ()) :: Type -> Type) | Since: base-4.9.0.0
Instance details Defined in Data.Foldable Methods fold :: Monoid m => URec (Ptr ()) m -> m Source # foldMap :: Monoid m => (a -> m) -> URec (Ptr ()) a -> m Source # foldMap' :: Monoid m => (a -> m) -> URec (Ptr ()) a -> m Source # foldr :: (a -> b -> b) -> b -> URec (Ptr ()) a -> b Source # foldr' :: (a -> b -> b) -> b -> URec (Ptr ()) a -> b Source # foldl :: (b -> a -> b) -> b -> URec (Ptr ()) a -> b Source # foldl' :: (b -> a -> b) -> b -> URec (Ptr ()) a -> b Source # foldr1 :: (a -> a -> a) -> URec (Ptr ()) a -> a Source # foldl1 :: (a -> a -> a) -> URec (Ptr ()) a -> a Source # toList :: URec (Ptr ()) a -> [a] Source # null :: URec (Ptr ()) a -> Bool Source # length :: URec (Ptr ()) a -> Int Source # elem :: Eq a => a -> URec (Ptr ()) a -> Bool Source # maximum :: Ord a => URec (Ptr ()) a -> a Source # minimum :: Ord a => URec (Ptr ()) a -> a Source # sum :: Num a => URec (Ptr ()) a -> a Source # product :: Num a => URec (Ptr ()) a -> a Source #
Traversable (URec (Ptr ()) :: Type -> Type) | Since: base-4.9.0.0
Instance details Defined in Data.Traversable Methods traverse :: Applicative f => (a -> f b) -> URec (Ptr ()) a -> f (URec (Ptr ()) b) Source # sequenceA :: Applicative f => URec (Ptr ()) (f a) -> f (URec (Ptr ()) a) Source # mapM :: Monad m => (a -> m b) -> URec (Ptr ()) a -> m (URec (Ptr ()) b) Source # sequence :: Monad m => URec (Ptr ()) (m a) -> m (URec (Ptr ()) a) Source #

withArray :: Storable a => [a] -> (Ptr a -> IO b) -> IO b Source #

Temporarily store a list of storable values in memory (like `with`, but for multiple elements).

allocaArray :: Storable a => Int -> (Ptr a -> IO b) -> IO b Source #

Temporarily allocate space for the given number of elements (like `alloca`, but for multiple elements).

maybeWith :: (a -> (Ptr b -> IO c) -> IO c) -> Maybe a -> (Ptr b -> IO c) -> IO c Source #

Converts a `withXXX` combinator into one marshalling a value wrapped into a `Maybe`, using `nullPtr` to represent `Nothing`.

with :: Storable a => a -> (Ptr a -> IO b) -> IO b Source #

``with` val f` executes the computation `f`, passing as argument a pointer to a temporarily allocated block of memory into which `val` has been marshalled (the combination of `alloca` and `poke`).

The memory is freed when `f` terminates (either normally or via an exception), so the pointer passed to `f` must not be used after this.

allocaBytesAligned :: Int -> Int -> (Ptr a -> IO b) -> IO b Source #

allocaBytes :: Int -> (Ptr a -> IO b) -> IO b Source #

``allocaBytes` n f` executes the computation `f`, passing as argument a pointer to a temporarily allocated block of memory of `n` bytes. The block of memory is sufficiently aligned for any of the basic foreign types that fits into a memory block of the allocated size.

The memory is freed when `f` terminates (either normally or via an exception), so the pointer passed to `f` must not be used after this.

alloca :: Storable a => (Ptr a -> IO b) -> IO b Source #

``alloca` f` executes the computation `f`, passing as argument a pointer to a temporarily allocated block of memory sufficient to hold values of type `a`.

The memory is freed when `f` terminates (either normally or via an exception), so the pointer passed to `f` must not be used after this.

class Storable a where Source #

The member functions of this class facilitate writing values of primitive types to raw memory (which may have been allocated with the above mentioned routines) and reading values from blocks of raw memory. The class, furthermore, includes support for computing the storage requirements and alignment restrictions of storable types.

Memory addresses are represented as values of type ``Ptr` a`, for some `a` which is an instance of class `Storable`. The type argument to `Ptr` helps provide some valuable type safety in FFI code (you can't mix pointers of different types without an explicit cast), while helping the Haskell type system figure out which marshalling method is needed for a given pointer.

All marshalling between Haskell and a foreign language ultimately boils down to translating Haskell data structures into the binary representation of a corresponding data structure of the foreign language and vice versa. To code this marshalling in Haskell, it is necessary to manipulate primitive data types stored in unstructured memory blocks. The class `Storable` facilitates this manipulation on all types for which it is instantiated, which are the standard basic types of Haskell, the fixed size `Int` types (`Int8`, `Int16`, `Int32`, `Int64`), the fixed size `Word` types (`Word8`, `Word16`, `Word32`, `Word64`), `StablePtr`, all types from Foreign.C.Types, as well as `Ptr`.

Minimal complete definition

sizeOf, alignment, (peek | peekElemOff | peekByteOff), (poke | pokeElemOff | pokeByteOff)

Methods

sizeOf :: a -> Int Source #

Computes the storage requirements (in bytes) of the argument. The value of the argument is not used.

alignment :: a -> Int Source #

Computes the alignment constraint of the argument. An alignment constraint `x` is fulfilled by any address divisible by `x`. The value of the argument is not used.

peekElemOff :: Ptr a -> Int -> IO a Source #

Read a value from a memory area regarded as an array of values of the same kind. The first argument specifies the start address of the array and the second the index into the array (the first element of the array has index `0`). The following equality holds,

    peekElemOff addr idx = IOExts.fixIO $ \result ->
      peek (addr `plusPtr` (idx * sizeOf result))

Note that this is only a specification, not necessarily the concrete implementation of the function.

pokeElemOff :: Ptr a -> Int -> a -> IO () Source #

Write a value to a memory area regarded as an array of values of the same kind. The following equality holds:

    pokeElemOff addr idx x =
      poke (addr `plusPtr` (idx * sizeOf x)) x

peekByteOff :: Ptr b -> Int -> IO a Source #

Read a value from a memory location given by a base address and offset. The following equality holds:

    peekByteOff addr off = peek (addr `plusPtr` off)

pokeByteOff :: Ptr b -> Int -> a -> IO () Source #

Write a value to a memory location given by a base address and offset. The following equality holds:

    pokeByteOff addr off x = poke (addr `plusPtr` off) x

peek :: Ptr a -> IO a Source #

Read a value from the given memory location.

Note that the peek and poke functions might require properly aligned addresses to function correctly. This is architecture dependent; thus, portable code should ensure that when peeking or poking values of some type `a`, the alignment constraint for `a`, as given by the function `alignment` is fulfilled.

poke :: Ptr a -> a -> IO () Source #

Write the given value to the given memory location. Alignment restrictions might apply; see `peek`.

#### Instances

Instances details

Storable Bool | Since: base-2.1
Instance details Defined in Foreign.Storable Methods sizeOf :: Bool -> Int Source # alignment :: Bool -> Int Source # peekElemOff :: Ptr Bool -> Int -> IO Bool Source # pokeElemOff :: Ptr Bool -> Int -> Bool -> IO () Source # peekByteOff :: Ptr b -> Int -> IO Bool Source # pokeByteOff :: Ptr b -> Int -> Bool -> IO () Source # peek :: Ptr Bool -> IO Bool Source # poke :: Ptr Bool -> Bool -> IO () Source #
Storable Char | Since: base-2.1
Instance details Defined in Foreign.Storable Methods sizeOf :: Char -> Int Source # alignment :: Char -> Int Source # peekElemOff :: Ptr Char -> Int -> IO Char Source # pokeElemOff :: Ptr Char -> Int -> Char -> IO () Source # peekByteOff :: Ptr b -> Int -> IO Char Source # pokeByteOff :: Ptr b -> Int -> Char -> IO () Source # peek :: Ptr Char -> IO Char Source # poke :: Ptr Char -> Char -> IO () Source #
Storable Double | Since: base-2.1
Instance details Defined in Foreign.Storable Methods sizeOf :: Double -> Int Source # alignment :: Double -> Int Source # peekElemOff :: Ptr Double -> Int -> IO Double Source # pokeElemOff :: Ptr Double -> Int -> Double -> IO () Source # peekByteOff :: Ptr b -> Int -> IO Double Source # pokeByteOff :: Ptr b -> Int -> Double -> IO () Source # peek :: Ptr Double -> IO Double Source # poke :: Ptr Double -> Double -> IO () Source #
Storable Float | Since: base-2.1
Instance details Defined in Foreign.Storable Methods sizeOf :: Float -> Int Source # alignment :: Float -> Int Source # peekElemOff :: Ptr Float -> Int -> IO Float Source # pokeElemOff :: Ptr Float -> Int -> Float -> IO () Source # peekByteOff :: Ptr b -> Int -> IO Float Source # pokeByteOff :: Ptr b -> Int -> Float -> IO () Source # peek :: Ptr Float -> IO Float Source # poke :: Ptr Float -> Float -> IO () Source #
Storable Int | Since: base-2.1
Instance details Defined in Foreign.Storable Methods sizeOf :: Int -> Int Source # alignment :: Int -> Int Source # peekElemOff :: Ptr Int -> Int -> IO Int Source # pokeElemOff :: Ptr Int -> Int -> Int -> IO () Source # peekByteOff :: Ptr b -> Int -> IO Int Source # pokeByteOff :: Ptr b -> Int -> Int -> IO () Source # peek :: Ptr Int -> IO Int Source # poke :: Ptr Int -> Int -> IO () Source #
Storable Int8 | Since: base-2.1
Instance details Defined in Foreign.Storable Methods sizeOf :: Int8 -> Int Source # alignment :: Int8 -> Int Source # peekElemOff :: Ptr Int8 -> Int -> IO Int8 Source # pokeElemOff :: Ptr Int8 -> Int -> Int8 -> IO () Source # peekByteOff :: Ptr b -> Int -> IO Int8 Source # pokeByteOff :: Ptr b -> Int -> Int8 -> IO () Source # peek :: Ptr Int8 -> IO Int8 Source # poke :: Ptr Int8 -> Int8 -> IO () Source #
Storable Int16 | Since: base-2.1
Instance details Defined in Foreign.Storable Methods sizeOf :: Int16 -> Int Source # alignment :: Int16 -> Int Source # peekElemOff :: Ptr Int16 -> Int -> IO Int16 Source # pokeElemOff :: Ptr Int16 -> Int -> Int16 -> IO () Source # peekByteOff :: Ptr b -> Int -> IO Int16 Source # pokeByteOff :: Ptr b -> Int -> Int16 -> IO () Source # peek :: Ptr Int16 -> IO Int16 Source # poke :: Ptr Int16 -> Int16 -> IO () Source #
Storable Int32 | Since: base-2.1
Instance details Defined in Foreign.Storable Methods sizeOf :: Int32 -> Int Source # alignment :: Int32 -> Int Source # peekElemOff :: Ptr Int32 -> Int -> IO Int32 Source # pokeElemOff :: Ptr Int32 -> Int -> Int32 -> IO () Source # peekByteOff :: Ptr b -> Int -> IO Int32 Source # pokeByteOff :: Ptr b -> Int -> Int32 -> IO () Source # peek :: Ptr Int32 -> IO Int32 Source # poke :: Ptr Int32 -> Int32 -> IO () Source #
Storable Int64 | Since: base-2.1
Instance details Defined in Foreign.Storable Methods sizeOf :: Int64 -> Int Source # alignment :: Int64 -> Int Source # peekElemOff :: Ptr Int64 -> Int -> IO Int64 Source # pokeElemOff :: Ptr Int64 -> Int -> Int64 -> IO () Source # peekByteOff :: Ptr b -> Int -> IO Int64 Source # pokeByteOff :: Ptr b -> Int -> Int64 -> IO () Source # peek :: Ptr Int64 -> IO Int64 Source # poke :: Ptr Int64 -> Int64 -> IO () Source #
Storable Word | Since: base-2.1
Instance details Defined in Foreign.Storable Methods sizeOf :: Word -> Int Source # alignment :: Word -> Int Source # peekElemOff :: Ptr Word -> Int -> IO Word Source # pokeElemOff :: Ptr Word -> Int -> Word -> IO () Source # peekByteOff :: Ptr b -> Int -> IO Word Source # pokeByteOff :: Ptr b -> Int -> Word -> IO () Source # peek :: Ptr Word -> IO Word Source # poke :: Ptr Word -> Word -> IO () Source #
Storable Word8 | Since: base-2.1
Instance details Defined in Foreign.Storable Methods sizeOf :: Word8 -> Int Source # alignment :: Word8 -> Int Source # peekElemOff :: Ptr Word8 -> Int -> IO Word8 Source # pokeElemOff :: Ptr Word8 -> Int -> Word8 -> IO () Source # peekByteOff :: Ptr b -> Int -> IO Word8 Source # pokeByteOff :: Ptr b -> Int -> Word8 -> IO () Source # peek :: Ptr Word8 -> IO Word8 Source # poke :: Ptr Word8 -> Word8 -> IO () Source #
Storable Word16 | Since: base-2.1
Instance details Defined in Foreign.Storable Methods sizeOf :: Word16 -> Int Source # alignment :: Word16 -> Int Source # peekElemOff :: Ptr Word16 -> Int -> IO Word16 Source # pokeElemOff :: Ptr Word16 -> Int -> Word16 -> IO () Source # peekByteOff :: Ptr b -> Int -> IO Word16 Source # pokeByteOff :: Ptr b -> Int -> Word16 -> IO () Source # peek :: Ptr Word16 -> IO Word16 Source # poke :: Ptr Word16 -> Word16 -> IO () Source #
Storable Word32 | Since: base-2.1
Instance details Defined in Foreign.Storable Methods sizeOf :: Word32 -> Int Source # alignment :: Word32 -> Int Source # peekElemOff :: Ptr Word32 -> Int -> IO Word32 Source # pokeElemOff :: Ptr Word32 -> Int -> Word32 -> IO () Source # peekByteOff :: Ptr b -> Int -> IO Word32 Source # pokeByteOff :: Ptr b -> Int -> Word32 -> IO () Source # peek :: Ptr Word32 -> IO Word32 Source # poke :: Ptr Word32 -> Word32 -> IO () Source #
Storable Word64 | Since: base-2.1
Instance details Defined in Foreign.Storable Methods sizeOf :: Word64 -> Int Source # alignment :: Word64 -> Int Source # peekElemOff :: Ptr Word64 -> Int -> IO Word64 Source # pokeElemOff :: Ptr Word64 -> Int -> Word64 -> IO () Source # peekByteOff :: Ptr b -> Int -> IO Word64 Source # pokeByteOff :: Ptr b -> Int -> Word64 -> IO () Source # peek :: Ptr Word64 -> IO Word64 Source # poke :: Ptr Word64 -> Word64 -> IO () Source #
Storable () | Since: base-4.9.0.0
Instance details Defined in Foreign.Storable Methods sizeOf :: () -> Int Source # alignment :: () -> Int Source # peekElemOff :: Ptr () -> Int -> IO () Source # pokeElemOff :: Ptr () -> Int -> () -> IO () Source # peekByteOff :: Ptr b -> Int -> IO () Source # pokeByteOff :: Ptr b -> Int -> () -> IO () Source # peek :: Ptr () -> IO () Source # poke :: Ptr () -> () -> IO () Source #
Storable CDev |
Instance details Defined in System.Posix.Types Methods sizeOf :: CDev -> Int Source # alignment :: CDev -> Int Source # peekElemOff :: Ptr CDev -> Int -> IO CDev Source # pokeElemOff :: Ptr CDev -> Int -> CDev -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CDev Source # pokeByteOff :: Ptr b -> Int -> CDev -> IO () Source # peek :: Ptr CDev -> IO CDev Source # poke :: Ptr CDev -> CDev -> IO () Source #
Storable CIno |
Instance details Defined in System.Posix.Types Methods sizeOf :: CIno -> Int Source # alignment :: CIno -> Int Source # peekElemOff :: Ptr CIno -> Int -> IO CIno Source # pokeElemOff :: Ptr CIno -> Int -> CIno -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CIno Source # pokeByteOff :: Ptr b -> Int -> CIno -> IO () Source # peek :: Ptr CIno -> IO CIno Source # poke :: Ptr CIno -> CIno -> IO () Source #
Storable CMode |
Instance details Defined in System.Posix.Types Methods sizeOf :: CMode -> Int Source # alignment :: CMode -> Int Source # peekElemOff :: Ptr CMode -> Int -> IO CMode Source # pokeElemOff :: Ptr CMode -> Int -> CMode -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CMode Source # pokeByteOff :: Ptr b -> Int -> CMode -> IO () Source # peek :: Ptr CMode -> IO CMode Source # poke :: Ptr CMode -> CMode -> IO () Source #
Storable COff |
Instance details Defined in System.Posix.Types Methods sizeOf :: COff -> Int Source # alignment :: COff -> Int Source # peekElemOff :: Ptr COff -> Int -> IO COff Source # pokeElemOff :: Ptr COff -> Int -> COff -> IO () Source # peekByteOff :: Ptr b -> Int -> IO COff Source # pokeByteOff :: Ptr b -> Int -> COff -> IO () Source # peek :: Ptr COff -> IO COff Source # poke :: Ptr COff -> COff -> IO () Source #
Storable CPid |
Instance details Defined in System.Posix.Types Methods sizeOf :: CPid -> Int Source # alignment :: CPid -> Int Source # peekElemOff :: Ptr CPid -> Int -> IO CPid Source # pokeElemOff :: Ptr CPid -> Int -> CPid -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CPid Source # pokeByteOff :: Ptr b -> Int -> CPid -> IO () Source # peek :: Ptr CPid -> IO CPid Source # poke :: Ptr CPid -> CPid -> IO () Source #
Storable CSsize |
Instance details Defined in System.Posix.Types Methods sizeOf :: CSsize -> Int Source # alignment :: CSsize -> Int Source # peekElemOff :: Ptr CSsize -> Int -> IO CSsize Source # pokeElemOff :: Ptr CSsize -> Int -> CSsize -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CSsize Source # pokeByteOff :: Ptr b -> Int -> CSsize -> IO () Source # peek :: Ptr CSsize -> IO CSsize Source # poke :: Ptr CSsize -> CSsize -> IO () Source #
Storable CGid |
Instance details Defined in System.Posix.Types Methods sizeOf :: CGid -> Int Source # alignment :: CGid -> Int Source # peekElemOff :: Ptr CGid -> Int -> IO CGid Source # pokeElemOff :: Ptr CGid -> Int -> CGid -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CGid Source # pokeByteOff :: Ptr b -> Int -> CGid -> IO () Source # peek :: Ptr CGid -> IO CGid Source # poke :: Ptr CGid -> CGid -> IO () Source #
Storable CNlink |
Instance details Defined in System.Posix.Types Methods sizeOf :: CNlink -> Int Source # alignment :: CNlink -> Int Source # peekElemOff :: Ptr CNlink -> Int -> IO CNlink Source # pokeElemOff :: Ptr CNlink -> Int -> CNlink -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CNlink Source # pokeByteOff :: Ptr b -> Int -> CNlink -> IO () Source # peek :: Ptr CNlink -> IO CNlink Source # poke :: Ptr CNlink -> CNlink -> IO () Source #
Storable CUid |
Instance details Defined in System.Posix.Types Methods sizeOf :: CUid -> Int Source # alignment :: CUid -> Int Source # peekElemOff :: Ptr CUid -> Int -> IO CUid Source # pokeElemOff :: Ptr CUid -> Int -> CUid -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CUid Source # pokeByteOff :: Ptr b -> Int -> CUid -> IO () Source # peek :: Ptr CUid -> IO CUid Source # poke :: Ptr CUid -> CUid -> IO () Source #
Storable CCc |
Instance details Defined in System.Posix.Types Methods sizeOf :: CCc -> Int Source # alignment :: CCc -> Int Source # peekElemOff :: Ptr CCc -> Int -> IO CCc Source # pokeElemOff :: Ptr CCc -> Int -> CCc -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CCc Source # pokeByteOff :: Ptr b -> Int -> CCc -> IO () Source # peek :: Ptr CCc -> IO CCc Source # poke :: Ptr CCc -> CCc -> IO () Source #
Storable CSpeed |
Instance details Defined in System.Posix.Types Methods sizeOf :: CSpeed -> Int Source # alignment :: CSpeed -> Int Source # peekElemOff :: Ptr CSpeed -> Int -> IO CSpeed Source # pokeElemOff :: Ptr CSpeed -> Int -> CSpeed -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CSpeed Source # pokeByteOff :: Ptr b -> Int -> CSpeed -> IO () Source # peek :: Ptr CSpeed -> IO CSpeed Source # poke :: Ptr CSpeed -> CSpeed -> IO () Source #
Storable CTcflag |
Instance details Defined in System.Posix.Types Methods sizeOf :: CTcflag -> Int Source # alignment :: CTcflag -> Int Source # peekElemOff :: Ptr CTcflag -> Int -> IO CTcflag Source # pokeElemOff :: Ptr CTcflag -> Int -> CTcflag -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CTcflag Source # pokeByteOff :: Ptr b -> Int -> CTcflag -> IO () Source # peek :: Ptr CTcflag -> IO CTcflag Source # poke :: Ptr CTcflag -> CTcflag -> IO () Source #
Storable CRLim |
Instance details Defined in System.Posix.Types Methods sizeOf :: CRLim -> Int Source # alignment :: CRLim -> Int Source # peekElemOff :: Ptr CRLim -> Int -> IO CRLim Source # pokeElemOff :: Ptr CRLim -> Int -> CRLim -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CRLim Source # pokeByteOff :: Ptr b -> Int -> CRLim -> IO () Source # peek :: Ptr CRLim -> IO CRLim Source # poke :: Ptr CRLim -> CRLim -> IO () Source #
Storable CBlkSize |
Instance details Defined in System.Posix.Types Methods sizeOf :: CBlkSize -> Int Source # alignment :: CBlkSize -> Int Source # peekElemOff :: Ptr CBlkSize -> Int -> IO CBlkSize Source # pokeElemOff :: Ptr CBlkSize -> Int -> CBlkSize -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CBlkSize Source # pokeByteOff :: Ptr b -> Int -> CBlkSize -> IO () Source # peek :: Ptr CBlkSize -> IO CBlkSize Source # poke :: Ptr CBlkSize -> CBlkSize -> IO () Source #
Storable CBlkCnt |
Instance details Defined in System.Posix.Types Methods sizeOf :: CBlkCnt -> Int Source # alignment :: CBlkCnt -> Int Source # peekElemOff :: Ptr CBlkCnt -> Int -> IO CBlkCnt Source # pokeElemOff :: Ptr CBlkCnt -> Int -> CBlkCnt -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CBlkCnt Source # pokeByteOff :: Ptr b -> Int -> CBlkCnt -> IO () Source # peek :: Ptr CBlkCnt -> IO CBlkCnt Source # poke :: Ptr CBlkCnt -> CBlkCnt -> IO () Source #
Storable CClockId |
Instance details Defined in System.Posix.Types Methods sizeOf :: CClockId -> Int Source # alignment :: CClockId -> Int Source # peekElemOff :: Ptr CClockId -> Int -> IO CClockId Source # pokeElemOff :: Ptr CClockId -> Int -> CClockId -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CClockId Source # pokeByteOff :: Ptr b -> Int -> CClockId -> IO () Source # peek :: Ptr CClockId -> IO CClockId Source # poke :: Ptr CClockId -> CClockId -> IO () Source #
Storable CFsBlkCnt |
Instance details Defined in System.Posix.Types Methods sizeOf :: CFsBlkCnt -> Int Source # alignment :: CFsBlkCnt -> Int Source # peekElemOff :: Ptr CFsBlkCnt -> Int -> IO CFsBlkCnt Source # pokeElemOff :: Ptr CFsBlkCnt -> Int -> CFsBlkCnt -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CFsBlkCnt Source # pokeByteOff :: Ptr b -> Int -> CFsBlkCnt -> IO () Source # peek :: Ptr CFsBlkCnt -> IO CFsBlkCnt Source # poke :: Ptr CFsBlkCnt -> CFsBlkCnt -> IO () Source #
Storable CFsFilCnt |
Instance details Defined in System.Posix.Types Methods sizeOf :: CFsFilCnt -> Int Source # alignment :: CFsFilCnt -> Int Source # peekElemOff :: Ptr CFsFilCnt -> Int -> IO CFsFilCnt Source # pokeElemOff :: Ptr CFsFilCnt -> Int -> CFsFilCnt -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CFsFilCnt Source # pokeByteOff :: Ptr b -> Int -> CFsFilCnt -> IO () Source # peek :: Ptr CFsFilCnt -> IO CFsFilCnt Source # poke :: Ptr CFsFilCnt -> CFsFilCnt -> IO () Source #
Storable CId |
Instance details Defined in System.Posix.Types Methods sizeOf :: CId -> Int Source # alignment :: CId -> Int Source # peekElemOff :: Ptr CId -> Int -> IO CId Source # pokeElemOff :: Ptr CId -> Int -> CId -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CId Source # pokeByteOff :: Ptr b -> Int -> CId -> IO () Source # peek :: Ptr CId -> IO CId Source # poke :: Ptr CId -> CId -> IO () Source #
Storable CKey |
Instance details Defined in System.Posix.Types Methods sizeOf :: CKey -> Int Source # alignment :: CKey -> Int Source # peekElemOff :: Ptr CKey -> Int -> IO CKey Source # pokeElemOff :: Ptr CKey -> Int -> CKey -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CKey Source # pokeByteOff :: Ptr b -> Int -> CKey -> IO () Source # peek :: Ptr CKey -> IO CKey Source # poke :: Ptr CKey -> CKey -> IO () Source #
Storable CTimer |
Instance details Defined in System.Posix.Types Methods sizeOf :: CTimer -> Int Source # alignment :: CTimer -> Int Source # peekElemOff :: Ptr CTimer -> Int -> IO CTimer Source # pokeElemOff :: Ptr CTimer -> Int -> CTimer -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CTimer Source # pokeByteOff :: Ptr b -> Int -> CTimer -> IO () Source # peek :: Ptr CTimer -> IO CTimer Source # poke :: Ptr CTimer -> CTimer -> IO () Source #
Storable Fd |
Instance details Defined in System.Posix.Types Methods sizeOf :: Fd -> Int Source # alignment :: Fd -> Int Source # peekElemOff :: Ptr Fd -> Int -> IO Fd Source # pokeElemOff :: Ptr Fd -> Int -> Fd -> IO () Source # peekByteOff :: Ptr b -> Int -> IO Fd Source # pokeByteOff :: Ptr b -> Int -> Fd -> IO () Source # peek :: Ptr Fd -> IO Fd Source # poke :: Ptr Fd -> Fd -> IO () Source #
Storable CChar |
Instance details Defined in Foreign.C.Types Methods sizeOf :: CChar -> Int Source # alignment :: CChar -> Int Source # peekElemOff :: Ptr CChar -> Int -> IO CChar Source # pokeElemOff :: Ptr CChar -> Int -> CChar -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CChar Source # pokeByteOff :: Ptr b -> Int -> CChar -> IO () Source # peek :: Ptr CChar -> IO CChar Source # poke :: Ptr CChar -> CChar -> IO () Source #
Storable CSChar |
Instance details Defined in Foreign.C.Types Methods sizeOf :: CSChar -> Int Source # alignment :: CSChar -> Int Source # peekElemOff :: Ptr CSChar -> Int -> IO CSChar Source # pokeElemOff :: Ptr CSChar -> Int -> CSChar -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CSChar Source # pokeByteOff :: Ptr b -> Int -> CSChar -> IO () Source # peek :: Ptr CSChar -> IO CSChar Source # poke :: Ptr CSChar -> CSChar -> IO () Source #
Storable CUChar |
Instance details Defined in Foreign.C.Types Methods sizeOf :: CUChar -> Int Source # alignment :: CUChar -> Int Source # peekElemOff :: Ptr CUChar -> Int -> IO CUChar Source # pokeElemOff :: Ptr CUChar -> Int -> CUChar -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CUChar Source # pokeByteOff :: Ptr b -> Int -> CUChar -> IO () Source # peek :: Ptr CUChar -> IO CUChar Source # poke :: Ptr CUChar -> CUChar -> IO () Source #
Storable CShort |
Instance details Defined in Foreign.C.Types Methods sizeOf :: CShort -> Int Source # alignment :: CShort -> Int Source # peekElemOff :: Ptr CShort -> Int -> IO CShort Source # pokeElemOff :: Ptr CShort -> Int -> CShort -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CShort Source # pokeByteOff :: Ptr b -> Int -> CShort -> IO () Source # peek :: Ptr CShort -> IO CShort Source # poke :: Ptr CShort -> CShort -> IO () Source #
Storable CUShort |
Instance details Defined in Foreign.C.Types Methods sizeOf :: CUShort -> Int Source # alignment :: CUShort -> Int Source # peekElemOff :: Ptr CUShort -> Int -> IO CUShort Source # pokeElemOff :: Ptr CUShort -> Int -> CUShort -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CUShort Source # pokeByteOff :: Ptr b -> Int -> CUShort -> IO () Source # peek :: Ptr CUShort -> IO CUShort Source # poke :: Ptr CUShort -> CUShort -> IO () Source #
Storable CInt |
Instance details Defined in Foreign.C.Types Methods sizeOf :: CInt -> Int Source # alignment :: CInt -> Int Source # peekElemOff :: Ptr CInt -> Int -> IO CInt Source # pokeElemOff :: Ptr CInt -> Int -> CInt -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CInt Source # pokeByteOff :: Ptr b -> Int -> CInt -> IO () Source # peek :: Ptr CInt -> IO CInt Source # poke :: Ptr CInt -> CInt -> IO () Source #
Storable CUInt |
Instance details Defined in Foreign.C.Types Methods sizeOf :: CUInt -> Int Source # alignment :: CUInt -> Int Source # peekElemOff :: Ptr CUInt -> Int -> IO CUInt Source # pokeElemOff :: Ptr CUInt -> Int -> CUInt -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CUInt Source # pokeByteOff :: Ptr b -> Int -> CUInt -> IO () Source # peek :: Ptr CUInt -> IO CUInt Source # poke :: Ptr CUInt -> CUInt -> IO () Source #
Storable CLong |
Instance details Defined in Foreign.C.Types Methods sizeOf :: CLong -> Int Source # alignment :: CLong -> Int Source # peekElemOff :: Ptr CLong -> Int -> IO CLong Source # pokeElemOff :: Ptr CLong -> Int -> CLong -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CLong Source # pokeByteOff :: Ptr b -> Int -> CLong -> IO () Source # peek :: Ptr CLong -> IO CLong Source # poke :: Ptr CLong -> CLong -> IO () Source #
Storable CULong |
Instance details Defined in Foreign.C.Types Methods sizeOf :: CULong -> Int Source # alignment :: CULong -> Int Source # peekElemOff :: Ptr CULong -> Int -> IO CULong Source # pokeElemOff :: Ptr CULong -> Int -> CULong -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CULong Source # pokeByteOff :: Ptr b -> Int -> CULong -> IO () Source # peek :: Ptr CULong -> IO CULong Source # poke :: Ptr CULong -> CULong -> IO () Source #
Storable CLLong |
Instance details Defined in Foreign.C.Types Methods sizeOf :: CLLong -> Int Source # alignment :: CLLong -> Int Source # peekElemOff :: Ptr CLLong -> Int -> IO CLLong Source # pokeElemOff :: Ptr CLLong -> Int -> CLLong -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CLLong Source # pokeByteOff :: Ptr b -> Int -> CLLong -> IO () Source # peek :: Ptr CLLong -> IO CLLong Source # poke :: Ptr CLLong -> CLLong -> IO () Source #
Storable CULLong |
Instance details Defined in Foreign.C.Types Methods sizeOf :: CULLong -> Int Source # alignment :: CULLong -> Int Source # peekElemOff :: Ptr CULLong -> Int -> IO CULLong Source # pokeElemOff :: Ptr CULLong -> Int -> CULLong -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CULLong Source # pokeByteOff :: Ptr b -> Int -> CULLong -> IO () Source # peek :: Ptr CULLong -> IO CULLong Source # poke :: Ptr CULLong -> CULLong -> IO () Source #
Storable CBool |
Instance details Defined in Foreign.C.Types Methods sizeOf :: CBool -> Int Source # alignment :: CBool -> Int Source # peekElemOff :: Ptr CBool -> Int -> IO CBool Source # pokeElemOff :: Ptr CBool -> Int -> CBool -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CBool Source # pokeByteOff :: Ptr b -> Int -> CBool -> IO () Source # peek :: Ptr CBool -> IO CBool Source # poke :: Ptr CBool -> CBool -> IO () Source #
Storable CFloat |
Instance details Defined in Foreign.C.Types Methods sizeOf :: CFloat -> Int Source # alignment :: CFloat -> Int Source # peekElemOff :: Ptr CFloat -> Int -> IO CFloat Source # pokeElemOff :: Ptr CFloat -> Int -> CFloat -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CFloat Source # pokeByteOff :: Ptr b -> Int -> CFloat -> IO () Source # peek :: Ptr CFloat -> IO CFloat Source # poke :: Ptr CFloat -> CFloat -> IO () Source #
Storable CDouble |
Instance details Defined in Foreign.C.Types Methods sizeOf :: CDouble -> Int Source # alignment :: CDouble -> Int Source # peekElemOff :: Ptr CDouble -> Int -> IO CDouble Source # pokeElemOff :: Ptr CDouble -> Int -> CDouble -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CDouble Source # pokeByteOff :: Ptr b -> Int -> CDouble -> IO () Source # peek :: Ptr CDouble -> IO CDouble Source # poke :: Ptr CDouble -> CDouble -> IO () Source #
Storable CPtrdiff |
Instance details Defined in Foreign.C.Types Methods sizeOf :: CPtrdiff -> Int Source # alignment :: CPtrdiff -> Int Source # peekElemOff :: Ptr CPtrdiff -> Int -> IO CPtrdiff Source # pokeElemOff :: Ptr CPtrdiff -> Int -> CPtrdiff -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CPtrdiff Source # pokeByteOff :: Ptr b -> Int -> CPtrdiff -> IO () Source # peek :: Ptr CPtrdiff -> IO CPtrdiff Source # poke :: Ptr CPtrdiff -> CPtrdiff -> IO () Source #
Storable CSize |
Instance details Defined in Foreign.C.Types Methods sizeOf :: CSize -> Int Source # alignment :: CSize -> Int Source # peekElemOff :: Ptr CSize -> Int -> IO CSize Source # pokeElemOff :: Ptr CSize -> Int -> CSize -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CSize Source # pokeByteOff :: Ptr b -> Int -> CSize -> IO () Source # peek :: Ptr CSize -> IO CSize Source # poke :: Ptr CSize -> CSize -> IO () Source #
Storable CWchar |
Instance details Defined in Foreign.C.Types Methods sizeOf :: CWchar -> Int Source # alignment :: CWchar -> Int Source # peekElemOff :: Ptr CWchar -> Int -> IO CWchar Source # pokeElemOff :: Ptr CWchar -> Int -> CWchar -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CWchar Source # pokeByteOff :: Ptr b -> Int -> CWchar -> IO () Source # peek :: Ptr CWchar -> IO CWchar Source # poke :: Ptr CWchar -> CWchar -> IO () Source #
Storable CSigAtomic |
Instance details Defined in Foreign.C.Types Methods sizeOf :: CSigAtomic -> Int Source # alignment :: CSigAtomic -> Int Source # peekElemOff :: Ptr CSigAtomic -> Int -> IO CSigAtomic Source # pokeElemOff :: Ptr CSigAtomic -> Int -> CSigAtomic -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CSigAtomic Source # pokeByteOff :: Ptr b -> Int -> CSigAtomic -> IO () Source # peek :: Ptr CSigAtomic -> IO CSigAtomic Source # poke :: Ptr CSigAtomic -> CSigAtomic -> IO () Source #
Storable CClock |
Instance details Defined in Foreign.C.Types Methods sizeOf :: CClock -> Int Source # alignment :: CClock -> Int Source # peekElemOff :: Ptr CClock -> Int -> IO CClock Source # pokeElemOff :: Ptr CClock -> Int -> CClock -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CClock Source # pokeByteOff :: Ptr b -> Int -> CClock -> IO () Source # peek :: Ptr CClock -> IO CClock Source # poke :: Ptr CClock -> CClock -> IO () Source #
Storable CTime |
Instance details Defined in Foreign.C.Types Methods sizeOf :: CTime -> Int Source # alignment :: CTime -> Int Source # peekElemOff :: Ptr CTime -> Int -> IO CTime Source # pokeElemOff :: Ptr CTime -> Int -> CTime -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CTime Source # pokeByteOff :: Ptr b -> Int -> CTime -> IO () Source # peek :: Ptr CTime -> IO CTime Source # poke :: Ptr CTime -> CTime -> IO () Source #
Storable CUSeconds |
Instance details Defined in Foreign.C.Types Methods sizeOf :: CUSeconds -> Int Source # alignment :: CUSeconds -> Int Source # peekElemOff :: Ptr CUSeconds -> Int -> IO CUSeconds Source # pokeElemOff :: Ptr CUSeconds -> Int -> CUSeconds -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CUSeconds Source # pokeByteOff :: Ptr b -> Int -> CUSeconds -> IO () Source # peek :: Ptr CUSeconds -> IO CUSeconds Source # poke :: Ptr CUSeconds -> CUSeconds -> IO () Source #
Storable CSUSeconds |
Instance details Defined in Foreign.C.Types Methods sizeOf :: CSUSeconds -> Int Source # alignment :: CSUSeconds -> Int Source # peekElemOff :: Ptr CSUSeconds -> Int -> IO CSUSeconds Source # pokeElemOff :: Ptr CSUSeconds -> Int -> CSUSeconds -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CSUSeconds Source # pokeByteOff :: Ptr b -> Int -> CSUSeconds -> IO () Source # peek :: Ptr CSUSeconds -> IO CSUSeconds Source # poke :: Ptr CSUSeconds -> CSUSeconds -> IO () Source #
Storable CIntPtr |
Instance details Defined in Foreign.C.Types Methods sizeOf :: CIntPtr -> Int Source # alignment :: CIntPtr -> Int Source # peekElemOff :: Ptr CIntPtr -> Int -> IO CIntPtr Source # pokeElemOff :: Ptr CIntPtr -> Int -> CIntPtr -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CIntPtr Source # pokeByteOff :: Ptr b -> Int -> CIntPtr -> IO () Source # peek :: Ptr CIntPtr -> IO CIntPtr Source # poke :: Ptr CIntPtr -> CIntPtr -> IO () Source #
Storable CUIntPtr |
Instance details Defined in Foreign.C.Types Methods sizeOf :: CUIntPtr -> Int Source # alignment :: CUIntPtr -> Int Source # peekElemOff :: Ptr CUIntPtr -> Int -> IO CUIntPtr Source # pokeElemOff :: Ptr CUIntPtr -> Int -> CUIntPtr -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CUIntPtr Source # pokeByteOff :: Ptr b -> Int -> CUIntPtr -> IO () Source # peek :: Ptr CUIntPtr -> IO CUIntPtr Source # poke :: Ptr CUIntPtr -> CUIntPtr -> IO () Source #
Storable CIntMax |
Instance details Defined in Foreign.C.Types Methods sizeOf :: CIntMax -> Int Source # alignment :: CIntMax -> Int Source # peekElemOff :: Ptr CIntMax -> Int -> IO CIntMax Source # pokeElemOff :: Ptr CIntMax -> Int -> CIntMax -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CIntMax Source # pokeByteOff :: Ptr b -> Int -> CIntMax -> IO () Source # peek :: Ptr CIntMax -> IO CIntMax Source # poke :: Ptr CIntMax -> CIntMax -> IO () Source #
Storable CUIntMax |
Instance details Defined in Foreign.C.Types Methods sizeOf :: CUIntMax -> Int Source # alignment :: CUIntMax -> Int Source # peekElemOff :: Ptr CUIntMax -> Int -> IO CUIntMax Source # pokeElemOff :: Ptr CUIntMax -> Int -> CUIntMax -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CUIntMax Source # pokeByteOff :: Ptr b -> Int -> CUIntMax -> IO () Source # peek :: Ptr CUIntMax -> IO CUIntMax Source # poke :: Ptr CUIntMax -> CUIntMax -> IO () Source #
Storable Fingerprint | Since: base-4.4.0.0
Instance details Defined in Foreign.Storable Methods sizeOf :: Fingerprint -> Int Source # alignment :: Fingerprint -> Int Source # peekElemOff :: Ptr Fingerprint -> Int -> IO Fingerprint Source # pokeElemOff :: Ptr Fingerprint -> Int -> Fingerprint -> IO () Source # peekByteOff :: Ptr b -> Int -> IO Fingerprint Source # pokeByteOff :: Ptr b -> Int -> Fingerprint -> IO () Source # peek :: Ptr Fingerprint -> IO Fingerprint Source # poke :: Ptr Fingerprint -> Fingerprint -> IO () Source #
Storable CTimeSpec |
Instance details Defined in System.Posix.Files.Common Methods sizeOf :: CTimeSpec -> Int Source # alignment :: CTimeSpec -> Int Source # peekElemOff :: Ptr CTimeSpec -> Int -> IO CTimeSpec Source # pokeElemOff :: Ptr CTimeSpec -> Int -> CTimeSpec -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CTimeSpec Source # pokeByteOff :: Ptr b -> Int -> CTimeSpec -> IO () Source # peek :: Ptr CTimeSpec -> IO CTimeSpec Source # poke :: Ptr CTimeSpec -> CTimeSpec -> IO () Source #
Storable CTimeVal |
Instance details Defined in System.Posix.Files.Common Methods sizeOf :: CTimeVal -> Int Source # alignment :: CTimeVal -> Int Source # peekElemOff :: Ptr CTimeVal -> Int -> IO CTimeVal Source # pokeElemOff :: Ptr CTimeVal -> Int -> CTimeVal -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CTimeVal Source # pokeByteOff :: Ptr b -> Int -> CTimeVal -> IO () Source # peek :: Ptr CTimeVal -> IO CTimeVal Source # poke :: Ptr CTimeVal -> CTimeVal -> IO () Source #
(Storable a, Integral a) => Storable (Ratio a) | Since: base-4.8.0.0
Instance details Defined in Foreign.Storable Methods sizeOf :: Ratio a -> Int Source # alignment :: Ratio a -> Int Source # peekElemOff :: Ptr (Ratio a) -> Int -> IO (Ratio a) Source # pokeElemOff :: Ptr (Ratio a) -> Int -> Ratio a -> IO () Source # peekByteOff :: Ptr b -> Int -> IO (Ratio a) Source # pokeByteOff :: Ptr b -> Int -> Ratio a -> IO () Source # peek :: Ptr (Ratio a) -> IO (Ratio a) Source # poke :: Ptr (Ratio a) -> Ratio a -> IO () Source #
Storable (StablePtr a) | Since: base-2.1
Instance details Defined in Foreign.Storable Methods sizeOf :: StablePtr a -> Int Source # alignment :: StablePtr a -> Int Source # peekElemOff :: Ptr (StablePtr a) -> Int -> IO (StablePtr a) Source # pokeElemOff :: Ptr (StablePtr a) -> Int -> StablePtr a -> IO () Source # peekByteOff :: Ptr b -> Int -> IO (StablePtr a) Source # pokeByteOff :: Ptr b -> Int -> StablePtr a -> IO () Source # peek :: Ptr (StablePtr a) -> IO (StablePtr a) Source # poke :: Ptr (StablePtr a) -> StablePtr a -> IO () Source #
Storable (Ptr a) | Since: base-2.1
Instance details Defined in Foreign.Storable Methods sizeOf :: Ptr a -> Int Source # alignment :: Ptr a -> Int Source # peekElemOff :: Ptr (Ptr a) -> Int -> IO (Ptr a) Source # pokeElemOff :: Ptr (Ptr a) -> Int -> Ptr a -> IO () Source # peekByteOff :: Ptr b -> Int -> IO (Ptr a) Source # pokeByteOff :: Ptr b -> Int -> Ptr a -> IO () Source # peek :: Ptr (Ptr a) -> IO (Ptr a) Source # poke :: Ptr (Ptr a) -> Ptr a -> IO () Source #
Storable (FunPtr a) | Since: base-2.1
Instance details Defined in Foreign.Storable Methods sizeOf :: FunPtr a -> Int Source # alignment :: FunPtr a -> Int Source # peekElemOff :: Ptr (FunPtr a) -> Int -> IO (FunPtr a) Source # pokeElemOff :: Ptr (FunPtr a) -> Int -> FunPtr a -> IO () Source # peekByteOff :: Ptr b -> Int -> IO (FunPtr a) Source # pokeByteOff :: Ptr b -> Int -> FunPtr a -> IO () Source # peek :: Ptr (FunPtr a) -> IO (FunPtr a) Source # poke :: Ptr (FunPtr a) -> FunPtr a -> IO () Source #

plusPtr :: Ptr a -> Int -> Ptr b Source #

Advances the given address by the given offset in bytes.

nullPtr :: Ptr a Source #

The constant `nullPtr` contains a distinguished value of `Ptr` that is not associated with a valid memory location.

throwErrnoPathIfMinus1_ :: (Eq a, Num a) => String -> FilePath -> IO a -> IO () Source #

as `throwErrnoIfMinus1_`, but exceptions include the given path when appropriate.

throwErrnoIfNull :: String -> IO (Ptr a) -> IO (Ptr a) Source #

Throw an `IOError` corresponding to the current value of `getErrno` if the `IO` action returns `nullPtr`.

throwErrnoIfMinus1Retry_ :: (Eq a, Num a) => String -> IO a -> IO () Source #

as `throwErrnoIfMinus1`, but discards the result.

throwErrnoIfMinus1_ :: (Eq a, Num a) => String -> IO a -> IO () Source #

as `throwErrnoIfMinus1`, but discards the result.

withCWString :: String -> (CWString -> IO a) -> IO a Source #

Marshal a Haskell string into a NUL terminated C wide string using temporary storage.

- the Haskell string may not contain any NUL characters
- the memory is freed when the subcomputation terminates (either normally or via an exception), so the pointer to the temporary storage must not be used after this.

peekCWStringLen :: CWStringLen -> IO String Source #

Marshal a C wide string with explicit length into a Haskell string.

withCString :: String -> (CString -> IO a) -> IO a Source #

Marshal a Haskell string into a NUL terminated C string using temporary storage.

- the Haskell string may not contain any NUL characters
- the memory is freed when the subcomputation terminates (either normally or via an exception), so the pointer to the temporary storage must not be used after this.

peekCString :: CString -> IO String Source #

Marshal a NUL terminated C string into a Haskell string.

type CString = Ptr CChar Source #

A C string is a reference to an array of C characters terminated by NUL.

type CWString = Ptr CWchar Source #

A C wide string is a reference to an array of C wide characters terminated by NUL.

newtype CUChar Source #

Haskell type representing the C `unsigned char` type.

Constructors

CUChar Word8 |

#### Instances

Instances details

Bounded CUChar |
Instance details Defined in Foreign.C.Types Methods minBound :: CUChar Source # maxBound :: CUChar Source #
Enum CUChar |
Instance details Defined in Foreign.C.Types Methods succ :: CUChar -> CUChar Source # pred :: CUChar -> CUChar Source # toEnum :: Int -> CUChar Source # fromEnum :: CUChar -> Int Source # enumFrom :: CUChar -> [CUChar] Source # enumFromThen :: CUChar -> CUChar -> [CUChar] Source # enumFromTo :: CUChar -> CUChar -> [CUChar] Source # enumFromThenTo :: CUChar -> CUChar -> CUChar -> [CUChar] Source #
Eq CUChar |
Instance details Defined in Foreign.C.Types Methods (==) :: CUChar -> CUChar -> Bool # (/=) :: CUChar -> CUChar -> Bool #
Integral CUChar |
Instance details Defined in Foreign.C.Types Methods quot :: CUChar -> CUChar -> CUChar Source # rem :: CUChar -> CUChar -> CUChar Source # div :: CUChar -> CUChar -> CUChar Source # mod :: CUChar -> CUChar -> CUChar Source # quotRem :: CUChar -> CUChar -> (CUChar, CUChar) Source # divMod :: CUChar -> CUChar -> (CUChar, CUChar) Source # toInteger :: CUChar -> Integer Source #
Num CUChar |
Instance details Defined in Foreign.C.Types Methods (+) :: CUChar -> CUChar -> CUChar Source # (-) :: CUChar -> CUChar -> CUChar Source # (*) :: CUChar -> CUChar -> CUChar Source # negate :: CUChar -> CUChar Source # abs :: CUChar -> CUChar Source # signum :: CUChar -> CUChar Source # fromInteger :: Integer -> CUChar Source #
Ord CUChar |
Instance details Defined in Foreign.C.Types Methods compare :: CUChar -> CUChar -> Ordering # (<) :: CUChar -> CUChar -> Bool # (<=) :: CUChar -> CUChar -> Bool # (>) :: CUChar -> CUChar -> Bool # (>=) :: CUChar -> CUChar -> Bool # max :: CUChar -> CUChar -> CUChar # min :: CUChar -> CUChar -> CUChar #
Read CUChar |
Instance details Defined in Foreign.C.Types Methods readsPrec :: Int -> ReadS CUChar Source # readList :: ReadS [CUChar] Source # readPrec :: ReadPrec CUChar Source # readListPrec :: ReadPrec [CUChar] Source #
Real CUChar |
Instance details Defined in Foreign.C.Types Methods toRational :: CUChar -> Rational Source #
Show CUChar |
Instance details Defined in Foreign.C.Types Methods showsPrec :: Int -> CUChar -> ShowS Source # show :: CUChar -> String Source # showList :: [CUChar] -> ShowS Source #
Storable CUChar |
Instance details Defined in Foreign.C.Types Methods sizeOf :: CUChar -> Int Source # alignment :: CUChar -> Int Source # peekElemOff :: Ptr CUChar -> Int -> IO CUChar Source # pokeElemOff :: Ptr CUChar -> Int -> CUChar -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CUChar Source # pokeByteOff :: Ptr b -> Int -> CUChar -> IO () Source # peek :: Ptr CUChar -> IO CUChar Source # poke :: Ptr CUChar -> CUChar -> IO () Source #
Bits CUChar |
Instance details Defined in Foreign.C.Types Methods (.&.) :: CUChar -> CUChar -> CUChar Source # (.|.) :: CUChar -> CUChar -> CUChar Source # xor :: CUChar -> CUChar -> CUChar Source # complement :: CUChar -> CUChar Source # shift :: CUChar -> Int -> CUChar Source # rotate :: CUChar -> Int -> CUChar Source # zeroBits :: CUChar Source # bit :: Int -> CUChar Source # setBit :: CUChar -> Int -> CUChar Source # clearBit :: CUChar -> Int -> CUChar Source # complementBit :: CUChar -> Int -> CUChar Source # testBit :: CUChar -> Int -> Bool Source # bitSizeMaybe :: CUChar -> Maybe Int Source # bitSize :: CUChar -> Int Source # isSigned :: CUChar -> Bool Source # shiftL :: CUChar -> Int -> CUChar Source # unsafeShiftL :: CUChar -> Int -> CUChar Source # shiftR :: CUChar -> Int -> CUChar Source # unsafeShiftR :: CUChar -> Int -> CUChar Source # rotateL :: CUChar -> Int -> CUChar Source # rotateR :: CUChar -> Int -> CUChar Source # popCount :: CUChar -> Int Source #
FiniteBits CUChar |
Instance details Defined in Foreign.C.Types Methods finiteBitSize :: CUChar -> Int Source # countLeadingZeros :: CUChar -> Int Source # countTrailingZeros :: CUChar -> Int Source #

newtype CUShort Source #

Haskell type representing the C `unsigned short` type.

Constructors

CUShort Word16 |

#### Instances

Instances details

Bounded CUShort |
Instance details Defined in Foreign.C.Types Methods minBound :: CUShort Source # maxBound :: CUShort Source #
Enum CUShort |
Instance details Defined in Foreign.C.Types Methods succ :: CUShort -> CUShort Source # pred :: CUShort -> CUShort Source # toEnum :: Int -> CUShort Source # fromEnum :: CUShort -> Int Source # enumFrom :: CUShort -> [CUShort] Source # enumFromThen :: CUShort -> CUShort -> [CUShort] Source # enumFromTo :: CUShort -> CUShort -> [CUShort] Source # enumFromThenTo :: CUShort -> CUShort -> CUShort -> [CUShort] Source #
Eq CUShort |
Instance details Defined in Foreign.C.Types Methods (==) :: CUShort -> CUShort -> Bool # (/=) :: CUShort -> CUShort -> Bool #
Integral CUShort |
Instance details Defined in Foreign.C.Types Methods quot :: CUShort -> CUShort -> CUShort Source # rem :: CUShort -> CUShort -> CUShort Source # div :: CUShort -> CUShort -> CUShort Source # mod :: CUShort -> CUShort -> CUShort Source # quotRem :: CUShort -> CUShort -> (CUShort, CUShort) Source # divMod :: CUShort -> CUShort -> (CUShort, CUShort) Source # toInteger :: CUShort -> Integer Source #
Num CUShort |
Instance details Defined in Foreign.C.Types Methods (+) :: CUShort -> CUShort -> CUShort Source # (-) :: CUShort -> CUShort -> CUShort Source # (*) :: CUShort -> CUShort -> CUShort Source # negate :: CUShort -> CUShort Source # abs :: CUShort -> CUShort Source # signum :: CUShort -> CUShort Source # fromInteger :: Integer -> CUShort Source #
Ord CUShort |
Instance details Defined in Foreign.C.Types Methods compare :: CUShort -> CUShort -> Ordering # (<) :: CUShort -> CUShort -> Bool # (<=) :: CUShort -> CUShort -> Bool # (>) :: CUShort -> CUShort -> Bool # (>=) :: CUShort -> CUShort -> Bool # max :: CUShort -> CUShort -> CUShort # min :: CUShort -> CUShort -> CUShort #
Read CUShort |
Instance details Defined in Foreign.C.Types Methods readsPrec :: Int -> ReadS CUShort Source # readList :: ReadS [CUShort] Source # readPrec :: ReadPrec CUShort Source # readListPrec :: ReadPrec [CUShort] Source #
Real CUShort |
Instance details Defined in Foreign.C.Types Methods toRational :: CUShort -> Rational Source #
Show CUShort |
Instance details Defined in Foreign.C.Types Methods showsPrec :: Int -> CUShort -> ShowS Source # show :: CUShort -> String Source # showList :: [CUShort] -> ShowS Source #
Storable CUShort |
Instance details Defined in Foreign.C.Types Methods sizeOf :: CUShort -> Int Source # alignment :: CUShort -> Int Source # peekElemOff :: Ptr CUShort -> Int -> IO CUShort Source # pokeElemOff :: Ptr CUShort -> Int -> CUShort -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CUShort Source # pokeByteOff :: Ptr b -> Int -> CUShort -> IO () Source # peek :: Ptr CUShort -> IO CUShort Source # poke :: Ptr CUShort -> CUShort -> IO () Source #
Bits CUShort |
Instance details Defined in Foreign.C.Types Methods (.&.) :: CUShort -> CUShort -> CUShort Source # (.|.) :: CUShort -> CUShort -> CUShort Source # xor :: CUShort -> CUShort -> CUShort Source # complement :: CUShort -> CUShort Source # shift :: CUShort -> Int -> CUShort Source # rotate :: CUShort -> Int -> CUShort Source # zeroBits :: CUShort Source # bit :: Int -> CUShort Source # setBit :: CUShort -> Int -> CUShort Source # clearBit :: CUShort -> Int -> CUShort Source # complementBit :: CUShort -> Int -> CUShort Source # testBit :: CUShort -> Int -> Bool Source # bitSizeMaybe :: CUShort -> Maybe Int Source # bitSize :: CUShort -> Int Source # isSigned :: CUShort -> Bool Source # shiftL :: CUShort -> Int -> CUShort Source # unsafeShiftL :: CUShort -> Int -> CUShort Source # shiftR :: CUShort -> Int -> CUShort Source # unsafeShiftR :: CUShort -> Int -> CUShort Source # rotateL :: CUShort -> Int -> CUShort Source # rotateR :: CUShort -> Int -> CUShort Source # popCount :: CUShort -> Int Source #
FiniteBits CUShort |
Instance details Defined in Foreign.C.Types Methods finiteBitSize :: CUShort -> Int Source # countLeadingZeros :: CUShort -> Int Source # countTrailingZeros :: CUShort -> Int Source #

newtype CInt Source #

Haskell type representing the C `int` type.

Constructors

CInt Int32 |

#### Instances

Instances details

Bounded CInt |
Instance details Defined in Foreign.C.Types Methods minBound :: CInt Source # maxBound :: CInt Source #
Enum CInt |
Instance details Defined in Foreign.C.Types Methods succ :: CInt -> CInt Source # pred :: CInt -> CInt Source # toEnum :: Int -> CInt Source # fromEnum :: CInt -> Int Source # enumFrom :: CInt -> [CInt] Source # enumFromThen :: CInt -> CInt -> [CInt] Source # enumFromTo :: CInt -> CInt -> [CInt] Source # enumFromThenTo :: CInt -> CInt -> CInt -> [CInt] Source #
Eq CInt |
Instance details Defined in Foreign.C.Types Methods (==) :: CInt -> CInt -> Bool # (/=) :: CInt -> CInt -> Bool #
Integral CInt |
Instance details Defined in Foreign.C.Types Methods quot :: CInt -> CInt -> CInt Source # rem :: CInt -> CInt -> CInt Source # div :: CInt -> CInt -> CInt Source # mod :: CInt -> CInt -> CInt Source # quotRem :: CInt -> CInt -> (CInt, CInt) Source # divMod :: CInt -> CInt -> (CInt, CInt) Source # toInteger :: CInt -> Integer Source #
Num CInt |
Instance details Defined in Foreign.C.Types Methods (+) :: CInt -> CInt -> CInt Source # (-) :: CInt -> CInt -> CInt Source # (*) :: CInt -> CInt -> CInt Source # negate :: CInt -> CInt Source # abs :: CInt -> CInt Source # signum :: CInt -> CInt Source # fromInteger :: Integer -> CInt Source #
Ord CInt |
Instance details Defined in Foreign.C.Types Methods compare :: CInt -> CInt -> Ordering # (<) :: CInt -> CInt -> Bool # (<=) :: CInt -> CInt -> Bool # (>) :: CInt -> CInt -> Bool # (>=) :: CInt -> CInt -> Bool # max :: CInt -> CInt -> CInt # min :: CInt -> CInt -> CInt #
Read CInt |
Instance details Defined in Foreign.C.Types Methods readsPrec :: Int -> ReadS CInt Source # readList :: ReadS [CInt] Source # readPrec :: ReadPrec CInt Source # readListPrec :: ReadPrec [CInt] Source #
Real CInt |
Instance details Defined in Foreign.C.Types Methods toRational :: CInt -> Rational Source #
Show CInt |
Instance details Defined in Foreign.C.Types Methods showsPrec :: Int -> CInt -> ShowS Source # show :: CInt -> String Source # showList :: [CInt] -> ShowS Source #
Storable CInt |
Instance details Defined in Foreign.C.Types Methods sizeOf :: CInt -> Int Source # alignment :: CInt -> Int Source # peekElemOff :: Ptr CInt -> Int -> IO CInt Source # pokeElemOff :: Ptr CInt -> Int -> CInt -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CInt Source # pokeByteOff :: Ptr b -> Int -> CInt -> IO () Source # peek :: Ptr CInt -> IO CInt Source # poke :: Ptr CInt -> CInt -> IO () Source #
Bits CInt |
Instance details Defined in Foreign.C.Types Methods (.&.) :: CInt -> CInt -> CInt Source # (.|.) :: CInt -> CInt -> CInt Source # xor :: CInt -> CInt -> CInt Source # complement :: CInt -> CInt Source # shift :: CInt -> Int -> CInt Source # rotate :: CInt -> Int -> CInt Source # zeroBits :: CInt Source # bit :: Int -> CInt Source # setBit :: CInt -> Int -> CInt Source # clearBit :: CInt -> Int -> CInt Source # complementBit :: CInt -> Int -> CInt Source # testBit :: CInt -> Int -> Bool Source # bitSizeMaybe :: CInt -> Maybe Int Source # bitSize :: CInt -> Int Source # isSigned :: CInt -> Bool Source # shiftL :: CInt -> Int -> CInt Source # unsafeShiftL :: CInt -> Int -> CInt Source # shiftR :: CInt -> Int -> CInt Source # unsafeShiftR :: CInt -> Int -> CInt Source # rotateL :: CInt -> Int -> CInt Source # rotateR :: CInt -> Int -> CInt Source # popCount :: CInt -> Int Source #
FiniteBits CInt |
Instance details Defined in Foreign.C.Types Methods finiteBitSize :: CInt -> Int Source # countLeadingZeros :: CInt -> Int Source # countTrailingZeros :: CInt -> Int Source #

newtype CLong Source #

Haskell type representing the C `long` type.

Constructors

CLong Int64 |

#### Instances

Instances details

Bounded CLong |
Instance details Defined in Foreign.C.Types Methods minBound :: CLong Source # maxBound :: CLong Source #
Enum CLong |
Instance details Defined in Foreign.C.Types Methods succ :: CLong -> CLong Source # pred :: CLong -> CLong Source # toEnum :: Int -> CLong Source # fromEnum :: CLong -> Int Source # enumFrom :: CLong -> [CLong] Source # enumFromThen :: CLong -> CLong -> [CLong] Source # enumFromTo :: CLong -> CLong -> [CLong] Source # enumFromThenTo :: CLong -> CLong -> CLong -> [CLong] Source #
Eq CLong |
Instance details Defined in Foreign.C.Types Methods (==) :: CLong -> CLong -> Bool # (/=) :: CLong -> CLong -> Bool #
Integral CLong |
Instance details Defined in Foreign.C.Types Methods quot :: CLong -> CLong -> CLong Source # rem :: CLong -> CLong -> CLong Source # div :: CLong -> CLong -> CLong Source # mod :: CLong -> CLong -> CLong Source # quotRem :: CLong -> CLong -> (CLong, CLong) Source # divMod :: CLong -> CLong -> (CLong, CLong) Source # toInteger :: CLong -> Integer Source #
Num CLong |
Instance details Defined in Foreign.C.Types Methods (+) :: CLong -> CLong -> CLong Source # (-) :: CLong -> CLong -> CLong Source # (*) :: CLong -> CLong -> CLong Source # negate :: CLong -> CLong Source # abs :: CLong -> CLong Source # signum :: CLong -> CLong Source # fromInteger :: Integer -> CLong Source #
Ord CLong |
Instance details Defined in Foreign.C.Types Methods compare :: CLong -> CLong -> Ordering # (<) :: CLong -> CLong -> Bool # (<=) :: CLong -> CLong -> Bool # (>) :: CLong -> CLong -> Bool # (>=) :: CLong -> CLong -> Bool # max :: CLong -> CLong -> CLong # min :: CLong -> CLong -> CLong #
Read CLong |
Instance details Defined in Foreign.C.Types Methods readsPrec :: Int -> ReadS CLong Source # readList :: ReadS [CLong] Source # readPrec :: ReadPrec CLong Source # readListPrec :: ReadPrec [CLong] Source #
Real CLong |
Instance details Defined in Foreign.C.Types Methods toRational :: CLong -> Rational Source #
Show CLong |
Instance details Defined in Foreign.C.Types Methods showsPrec :: Int -> CLong -> ShowS Source # show :: CLong -> String Source # showList :: [CLong] -> ShowS Source #
Storable CLong |
Instance details Defined in Foreign.C.Types Methods sizeOf :: CLong -> Int Source # alignment :: CLong -> Int Source # peekElemOff :: Ptr CLong -> Int -> IO CLong Source # pokeElemOff :: Ptr CLong -> Int -> CLong -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CLong Source # pokeByteOff :: Ptr b -> Int -> CLong -> IO () Source # peek :: Ptr CLong -> IO CLong Source # poke :: Ptr CLong -> CLong -> IO () Source #
Bits CLong |
Instance details Defined in Foreign.C.Types Methods (.&.) :: CLong -> CLong -> CLong Source # (.|.) :: CLong -> CLong -> CLong Source # xor :: CLong -> CLong -> CLong Source # complement :: CLong -> CLong Source # shift :: CLong -> Int -> CLong Source # rotate :: CLong -> Int -> CLong Source # zeroBits :: CLong Source # bit :: Int -> CLong Source # setBit :: CLong -> Int -> CLong Source # clearBit :: CLong -> Int -> CLong Source # complementBit :: CLong -> Int -> CLong Source # testBit :: CLong -> Int -> Bool Source # bitSizeMaybe :: CLong -> Maybe Int Source # bitSize :: CLong -> Int Source # isSigned :: CLong -> Bool Source # shiftL :: CLong -> Int -> CLong Source # unsafeShiftL :: CLong -> Int -> CLong Source # shiftR :: CLong -> Int -> CLong Source # unsafeShiftR :: CLong -> Int -> CLong Source # rotateL :: CLong -> Int -> CLong Source # rotateR :: CLong -> Int -> CLong Source # popCount :: CLong -> Int Source #
FiniteBits CLong |
Instance details Defined in Foreign.C.Types Methods finiteBitSize :: CLong -> Int Source # countLeadingZeros :: CLong -> Int Source # countTrailingZeros :: CLong -> Int Source #

newtype CULong Source #

Haskell type representing the C `unsigned long` type.

Constructors

CULong Word64 |

#### Instances

Instances details

Bounded CULong |
Instance details Defined in Foreign.C.Types Methods minBound :: CULong Source # maxBound :: CULong Source #
Enum CULong |
Instance details Defined in Foreign.C.Types Methods succ :: CULong -> CULong Source # pred :: CULong -> CULong Source # toEnum :: Int -> CULong Source # fromEnum :: CULong -> Int Source # enumFrom :: CULong -> [CULong] Source # enumFromThen :: CULong -> CULong -> [CULong] Source # enumFromTo :: CULong -> CULong -> [CULong] Source # enumFromThenTo :: CULong -> CULong -> CULong -> [CULong] Source #
Eq CULong |
Instance details Defined in Foreign.C.Types Methods (==) :: CULong -> CULong -> Bool # (/=) :: CULong -> CULong -> Bool #
Integral CULong |
Instance details Defined in Foreign.C.Types Methods quot :: CULong -> CULong -> CULong Source # rem :: CULong -> CULong -> CULong Source # div :: CULong -> CULong -> CULong Source # mod :: CULong -> CULong -> CULong Source # quotRem :: CULong -> CULong -> (CULong, CULong) Source # divMod :: CULong -> CULong -> (CULong, CULong) Source # toInteger :: CULong -> Integer Source #
Num CULong |
Instance details Defined in Foreign.C.Types Methods (+) :: CULong -> CULong -> CULong Source # (-) :: CULong -> CULong -> CULong Source # (*) :: CULong -> CULong -> CULong Source # negate :: CULong -> CULong Source # abs :: CULong -> CULong Source # signum :: CULong -> CULong Source # fromInteger :: Integer -> CULong Source #
Ord CULong |
Instance details Defined in Foreign.C.Types Methods compare :: CULong -> CULong -> Ordering # (<) :: CULong -> CULong -> Bool # (<=) :: CULong -> CULong -> Bool # (>) :: CULong -> CULong -> Bool # (>=) :: CULong -> CULong -> Bool # max :: CULong -> CULong -> CULong # min :: CULong -> CULong -> CULong #
Read CULong |
Instance details Defined in Foreign.C.Types Methods readsPrec :: Int -> ReadS CULong Source # readList :: ReadS [CULong] Source # readPrec :: ReadPrec CULong Source # readListPrec :: ReadPrec [CULong] Source #
Real CULong |
Instance details Defined in Foreign.C.Types Methods toRational :: CULong -> Rational Source #
Show CULong |
Instance details Defined in Foreign.C.Types Methods showsPrec :: Int -> CULong -> ShowS Source # show :: CULong -> String Source # showList :: [CULong] -> ShowS Source #
Storable CULong |
Instance details Defined in Foreign.C.Types Methods sizeOf :: CULong -> Int Source # alignment :: CULong -> Int Source # peekElemOff :: Ptr CULong -> Int -> IO CULong Source # pokeElemOff :: Ptr CULong -> Int -> CULong -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CULong Source # pokeByteOff :: Ptr b -> Int -> CULong -> IO () Source # peek :: Ptr CULong -> IO CULong Source # poke :: Ptr CULong -> CULong -> IO () Source #
Bits CULong |
Instance details Defined in Foreign.C.Types Methods (.&.) :: CULong -> CULong -> CULong Source # (.|.) :: CULong -> CULong -> CULong Source # xor :: CULong -> CULong -> CULong Source # complement :: CULong -> CULong Source # shift :: CULong -> Int -> CULong Source # rotate :: CULong -> Int -> CULong Source # zeroBits :: CULong Source # bit :: Int -> CULong Source # setBit :: CULong -> Int -> CULong Source # clearBit :: CULong -> Int -> CULong Source # complementBit :: CULong -> Int -> CULong Source # testBit :: CULong -> Int -> Bool Source # bitSizeMaybe :: CULong -> Maybe Int Source # bitSize :: CULong -> Int Source # isSigned :: CULong -> Bool Source # shiftL :: CULong -> Int -> CULong Source # unsafeShiftL :: CULong -> Int -> CULong Source # shiftR :: CULong -> Int -> CULong Source # unsafeShiftR :: CULong -> Int -> CULong Source # rotateL :: CULong -> Int -> CULong Source # rotateR :: CULong -> Int -> CULong Source # popCount :: CULong -> Int Source #
FiniteBits CULong |
Instance details Defined in Foreign.C.Types Methods finiteBitSize :: CULong -> Int Source # countLeadingZeros :: CULong -> Int Source # countTrailingZeros :: CULong -> Int Source #

newtype CWchar Source #

Haskell type representing the C `wchar_t` type.

Constructors

CWchar Int32 |

#### Instances

Instances details

Bounded CWchar |
Instance details Defined in Foreign.C.Types Methods minBound :: CWchar Source # maxBound :: CWchar Source #
Enum CWchar |
Instance details Defined in Foreign.C.Types Methods succ :: CWchar -> CWchar Source # pred :: CWchar -> CWchar Source # toEnum :: Int -> CWchar Source # fromEnum :: CWchar -> Int Source # enumFrom :: CWchar -> [CWchar] Source # enumFromThen :: CWchar -> CWchar -> [CWchar] Source # enumFromTo :: CWchar -> CWchar -> [CWchar] Source # enumFromThenTo :: CWchar -> CWchar -> CWchar -> [CWchar] Source #
Eq CWchar |
Instance details Defined in Foreign.C.Types Methods (==) :: CWchar -> CWchar -> Bool # (/=) :: CWchar -> CWchar -> Bool #
Integral CWchar |
Instance details Defined in Foreign.C.Types Methods quot :: CWchar -> CWchar -> CWchar Source # rem :: CWchar -> CWchar -> CWchar Source # div :: CWchar -> CWchar -> CWchar Source # mod :: CWchar -> CWchar -> CWchar Source # quotRem :: CWchar -> CWchar -> (CWchar, CWchar) Source # divMod :: CWchar -> CWchar -> (CWchar, CWchar) Source # toInteger :: CWchar -> Integer Source #
Num CWchar |
Instance details Defined in Foreign.C.Types Methods (+) :: CWchar -> CWchar -> CWchar Source # (-) :: CWchar -> CWchar -> CWchar Source # (*) :: CWchar -> CWchar -> CWchar Source # negate :: CWchar -> CWchar Source # abs :: CWchar -> CWchar Source # signum :: CWchar -> CWchar Source # fromInteger :: Integer -> CWchar Source #
Ord CWchar |
Instance details Defined in Foreign.C.Types Methods compare :: CWchar -> CWchar -> Ordering # (<) :: CWchar -> CWchar -> Bool # (<=) :: CWchar -> CWchar -> Bool # (>) :: CWchar -> CWchar -> Bool # (>=) :: CWchar -> CWchar -> Bool # max :: CWchar -> CWchar -> CWchar # min :: CWchar -> CWchar -> CWchar #
Read CWchar |
Instance details Defined in Foreign.C.Types Methods readsPrec :: Int -> ReadS CWchar Source # readList :: ReadS [CWchar] Source # readPrec :: ReadPrec CWchar Source # readListPrec :: ReadPrec [CWchar] Source #
Real CWchar |
Instance details Defined in Foreign.C.Types Methods toRational :: CWchar -> Rational Source #
Show CWchar |
Instance details Defined in Foreign.C.Types Methods showsPrec :: Int -> CWchar -> ShowS Source # show :: CWchar -> String Source # showList :: [CWchar] -> ShowS Source #
Storable CWchar |
Instance details Defined in Foreign.C.Types Methods sizeOf :: CWchar -> Int Source # alignment :: CWchar -> Int Source # peekElemOff :: Ptr CWchar -> Int -> IO CWchar Source # pokeElemOff :: Ptr CWchar -> Int -> CWchar -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CWchar Source # pokeByteOff :: Ptr b -> Int -> CWchar -> IO () Source # peek :: Ptr CWchar -> IO CWchar Source # poke :: Ptr CWchar -> CWchar -> IO () Source #
Bits CWchar |
Instance details Defined in Foreign.C.Types Methods (.&.) :: CWchar -> CWchar -> CWchar Source # (.|.) :: CWchar -> CWchar -> CWchar Source # xor :: CWchar -> CWchar -> CWchar Source # complement :: CWchar -> CWchar Source # shift :: CWchar -> Int -> CWchar Source # rotate :: CWchar -> Int -> CWchar Source # zeroBits :: CWchar Source # bit :: Int -> CWchar Source # setBit :: CWchar -> Int -> CWchar Source # clearBit :: CWchar -> Int -> CWchar Source # complementBit :: CWchar -> Int -> CWchar Source # testBit :: CWchar -> Int -> Bool Source # bitSizeMaybe :: CWchar -> Maybe Int Source # bitSize :: CWchar -> Int Source # isSigned :: CWchar -> Bool Source # shiftL :: CWchar -> Int -> CWchar Source # unsafeShiftL :: CWchar -> Int -> CWchar Source # shiftR :: CWchar -> Int -> CWchar Source # unsafeShiftR :: CWchar -> Int -> CWchar Source # rotateL :: CWchar -> Int -> CWchar Source # rotateR :: CWchar -> Int -> CWchar Source # popCount :: CWchar -> Int Source #
FiniteBits CWchar |
Instance details Defined in Foreign.C.Types Methods finiteBitSize :: CWchar -> Int Source # countLeadingZeros :: CWchar -> Int Source # countTrailingZeros :: CWchar -> Int Source #

newtype CTime Source #

Haskell type representing the C `time_t` type.

Constructors

CTime Int64 |

#### Instances

Instances details

Enum CTime |
Instance details Defined in Foreign.C.Types Methods succ :: CTime -> CTime Source # pred :: CTime -> CTime Source # toEnum :: Int -> CTime Source # fromEnum :: CTime -> Int Source # enumFrom :: CTime -> [CTime] Source # enumFromThen :: CTime -> CTime -> [CTime] Source # enumFromTo :: CTime -> CTime -> [CTime] Source # enumFromThenTo :: CTime -> CTime -> CTime -> [CTime] Source #
Eq CTime |
Instance details Defined in Foreign.C.Types Methods (==) :: CTime -> CTime -> Bool # (/=) :: CTime -> CTime -> Bool #
Num CTime |
Instance details Defined in Foreign.C.Types Methods (+) :: CTime -> CTime -> CTime Source # (-) :: CTime -> CTime -> CTime Source # (*) :: CTime -> CTime -> CTime Source # negate :: CTime -> CTime Source # abs :: CTime -> CTime Source # signum :: CTime -> CTime Source # fromInteger :: Integer -> CTime Source #
Ord CTime |
Instance details Defined in Foreign.C.Types Methods compare :: CTime -> CTime -> Ordering # (<) :: CTime -> CTime -> Bool # (<=) :: CTime -> CTime -> Bool # (>) :: CTime -> CTime -> Bool # (>=) :: CTime -> CTime -> Bool # max :: CTime -> CTime -> CTime # min :: CTime -> CTime -> CTime #
Read CTime |
Instance details Defined in Foreign.C.Types Methods readsPrec :: Int -> ReadS CTime Source # readList :: ReadS [CTime] Source # readPrec :: ReadPrec CTime Source # readListPrec :: ReadPrec [CTime] Source #
Real CTime |
Instance details Defined in Foreign.C.Types Methods toRational :: CTime -> Rational Source #
Show CTime |
Instance details Defined in Foreign.C.Types Methods showsPrec :: Int -> CTime -> ShowS Source # show :: CTime -> String Source # showList :: [CTime] -> ShowS Source #
Storable CTime |
Instance details Defined in Foreign.C.Types Methods sizeOf :: CTime -> Int Source # alignment :: CTime -> Int Source # peekElemOff :: Ptr CTime -> Int -> IO CTime Source # pokeElemOff :: Ptr CTime -> Int -> CTime -> IO () Source # peekByteOff :: Ptr b -> Int -> IO CTime Source # pokeByteOff :: Ptr b -> Int -> CTime -> IO () Source # peek :: Ptr CTime -> IO CTime Source # poke :: Ptr CTime -> CTime -> IO () Source #

getFileSystemEncoding :: IO TextEncoding Source #

The Unicode encoding of the current locale, but allowing arbitrary undecodable bytes to be round-tripped through it.

This `TextEncoding` is used to decode and encode command line arguments and environment variables on non-Windows platforms.

On Windows, this encoding *should not* be used if possible because the use of code pages is deprecated: Strings should be retrieved via the "wide" W-family of UTF-16 APIs instead

Since: base-4.5.0.0

data IOErrorType Source #

An abstract type that contains a value for each variant of `IOError`.

Constructors

OtherError |
InappropriateType |
UnsupportedOperation |

#### Instances

Instances details

Eq IOErrorType | Since: base-4.1.0.0
Instance details Defined in GHC.IO.Exception Methods (==) :: IOErrorType -> IOErrorType -> Bool # (/=) :: IOErrorType -> IOErrorType -> Bool #
Show IOErrorType | Since: base-4.1.0.0
Instance details Defined in GHC.IO.Exception Methods showsPrec :: Int -> IOErrorType -> ShowS Source # show :: IOErrorType -> String Source # showList :: [IOErrorType] -> ShowS Source #

lookupEnv :: String -> IO (Maybe String) Source #

Return the value of the environment variable `var`, or `Nothing` if there is no such value.

For POSIX users, this is equivalent to `getEnv`.

Since: base-4.6.0.0

getEnv :: String -> IO String Source #

Computation `getEnv` `var` returns the value of the environment variable `var`. For the inverse, the `setEnv` function can be used.

This computation may fail with:

- `isDoesNotExistError` if the environment variable does not exist.

getArgs :: IO [String] Source #

Computation `getArgs` returns a list of the program's command line arguments (not including the program name).

exitFailure :: IO a Source #

The computation `exitFailure` is equivalent to `exitWith` `(``ExitFailure` exitfail`)`, where exitfail is implementation-dependent.

openBinaryTempFile :: FilePath -> String -> IO (FilePath, Handle) Source #

Like `openTempFile`, but opens the file in binary mode. See `openBinaryFile` for more comments.

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

``withBinaryFile` name mode act` opens a file using `openBinaryFile` and passes the resulting handle to the computation `act`. The handle will be closed on exit from `withBinaryFile`, whether by normal termination or by raising an exception.

hClose :: Handle -> IO () Source #

Computation `hClose` `hdl` makes handle `hdl` closed. Before the computation finishes, if `hdl` is writable its buffer is flushed as for `hFlush`. Performing `hClose` on a handle that has already been closed has no effect; doing so is not an error. All other operations on a closed handle will fail. If `hClose` fails for any reason, any further operations (apart from `hClose`) on the handle will still fail as if `hdl` had been successfully closed.

stderr :: Handle Source #

A handle managing output to the Haskell program's standard error channel.

hGetBuf :: Handle -> Ptr a -> Int -> IO Int Source #

`hGetBuf` `hdl buf count` reads data from the handle `hdl` into the buffer `buf` until either EOF is reached or `count` 8-bit bytes have been read. It returns the number of bytes actually read. This may be zero if EOF was reached before any data was read (or if `count` is zero).

`hGetBuf` never raises an EOF exception, instead it returns a value smaller than `count`.

If the handle is a pipe or socket, and the writing end is closed, `hGetBuf` will behave as if EOF was reached.

`hGetBuf` ignores the prevailing `TextEncoding` and `NewlineMode` on the `Handle`, and reads bytes directly.

hPutBuf :: Handle -> Ptr a -> Int -> IO () Source #

`hPutBuf` `hdl buf count` writes `count` 8-bit bytes from the buffer `buf` to the handle `hdl`. It returns ().

`hPutBuf` ignores any text encoding that applies to the `Handle`, writing the bytes directly to the underlying file or device.

`hPutBuf` ignores the prevailing `TextEncoding` and `NewlineMode` on the `Handle`, and writes bytes directly.

This operation may fail with:

- `ResourceVanished` if the handle is a pipe or socket, and the reading end is closed. (If this is a POSIX system, and the program has not asked to ignore SIGPIPE, then a SIGPIPE may be delivered instead, whose default action is to terminate the program).

hPutStrLn :: Handle -> String -> IO () Source #

The same as `hPutStr`, but adds a newline character.

hPutStr :: Handle -> String -> IO () Source #

Computation `hPutStr` `hdl s` writes the string `s` to the file or channel managed by `hdl`.

This operation may fail with:

- `isFullError` if the device is full; or
- `isPermissionError` if another system resource limit would be exceeded.

hFlush :: Handle -> IO () Source #

The action `hFlush` `hdl` causes any items buffered for output in handle `hdl` to be sent immediately to the operating system.

This operation may fail with:

- `isFullError` if the device is full;
- `isPermissionError` if a system resource limit would be exceeded. It is unspecified whether the characters in the buffer are discarded or retained under these circumstances.

stdout :: Handle Source #

A handle managing output to the Haskell program's standard output channel.

data Handle Source #

Haskell defines operations to read and write characters from and to files, represented by values of type `Handle`. Each value of this type is a handle: a record used by the Haskell run-time system to manage I/O with file system objects. A handle has at least the following properties:

- whether it manages input or output or both;
- whether it is open, closed or semi-closed;
- whether the object is seekable;
- whether buffering is disabled, or enabled on a line or block basis;
- a buffer (whose length may be zero).

Most handles will also have a current I/O position indicating where the next input or output operation will occur. A handle is readable if it manages only input or both input and output; likewise, it is writable if it manages only output or both input and output. A handle is open when first allocated. Once it is closed it can no longer be used for either input or output, though an implementation cannot re-use its storage while references remain to it. Handles are in the `Show` and `Eq` classes. The string produced by showing a handle is system dependent; it should include enough information to identify the handle for debugging. A handle is equal according to `==` only to itself; no attempt is made to compare the internal state of different handles for equality.

#### Instances

Instances details

Eq Handle | Since: base-4.1.0.0
Instance details Defined in GHC.IO.Handle.Types Methods (==) :: Handle -> Handle -> Bool # (/=) :: Handle -> Handle -> Bool #
Show Handle | Since: base-4.1.0.0
Instance details Defined in GHC.IO.Handle.Types Methods showsPrec :: Int -> Handle -> ShowS Source # show :: Handle -> String Source # showList :: [Handle] -> ShowS Source #

data IOMode Source #

See `openFile`

Constructors

ReadMode |
WriteMode |

#### Instances

Instances details

Enum IOMode | Since: base-4.2.0.0
Instance details Defined in GHC.IO.IOMode Methods succ :: IOMode -> IOMode Source # pred :: IOMode -> IOMode Source # toEnum :: Int -> IOMode Source # fromEnum :: IOMode -> Int Source # enumFrom :: IOMode -> [IOMode] Source # enumFromThen :: IOMode -> IOMode -> [IOMode] Source # enumFromTo :: IOMode -> IOMode -> [IOMode] Source # enumFromThenTo :: IOMode -> IOMode -> IOMode -> [IOMode] Source #
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 Methods compare :: IOMode -> IOMode -> Ordering # (<) :: IOMode -> IOMode -> Bool # (<=) :: IOMode -> IOMode -> Bool # (>) :: IOMode -> IOMode -> Bool # (>=) :: IOMode -> IOMode -> Bool # max :: IOMode -> IOMode -> IOMode # min :: IOMode -> IOMode -> IOMode #
Read IOMode | Since: base-4.2.0.0
Instance details Defined in GHC.IO.IOMode Methods readsPrec :: Int -> ReadS IOMode Source # readList :: ReadS [IOMode] Source # readPrec :: ReadPrec IOMode Source # readListPrec :: ReadPrec [IOMode] Source #
Show IOMode | Since: base-4.2.0.0
Instance details Defined in GHC.IO.IOMode Methods showsPrec :: Int -> IOMode -> ShowS Source # show :: IOMode -> String Source # showList :: [IOMode] -> ShowS Source #
Ix IOMode | Since: base-4.2.0.0
Instance details Defined in GHC.IO.IOMode Methods range :: (IOMode, IOMode) -> [IOMode] Source # index :: (IOMode, IOMode) -> IOMode -> Int Source # unsafeIndex :: (IOMode, IOMode) -> IOMode -> Int Source # inRange :: (IOMode, IOMode) -> IOMode -> Bool Source # rangeSize :: (IOMode, IOMode) -> Int Source # unsafeRangeSize :: (IOMode, IOMode) -> Int Source #

catchIOError :: IO a -> (IOError -> IO a) -> IO a Source #

The `catchIOError` function establishes a handler that receives any `IOError` raised in the action protected by `catchIOError`. An `IOError` is caught by the most recent handler established by one of the exception handling functions. These handlers are not selective: all `IOError`s are caught. Exception propagation must be explicitly provided in a handler by re-raising any unwanted exceptions. For example, in

    f = catchIOError g (\e -> if IO.isEOFError e then return [] else ioError e)

the function `f` returns `[]` when an end-of-file exception (cf. `isEOFError`) occurs in `g`; otherwise, the exception is propagated to the next outer handler.

When an exception propagates outside the main program, the Haskell system prints the associated `IOError` value and exits the program.

Non-I/O exceptions are not caught by this variant; to catch all exceptions, use `catch` from Control.Exception.

Since: base-4.4.0.0

modifyIOError :: (IOError -> IOError) -> IO a -> IO a Source #

Catch any `IOError` that occurs in the computation and throw a modified version.

ioeSetFileName :: IOError -> FilePath -> IOError Source #

ioeSetLocation :: IOError -> String -> IOError Source #

ioeSetErrorString :: IOError -> String -> IOError Source #

ioeGetLocation :: IOError -> String Source #

ioeGetErrorString :: IOError -> String Source #

ioeGetErrorType :: IOError -> IOErrorType Source #

permissionErrorType :: IOErrorType Source #

I/O error where the operation failed because the user does not have sufficient operating system privilege to perform that operation.

illegalOperationErrorType :: IOErrorType Source #

I/O error where the operation is not possible.

isPermissionError :: IOError -> Bool Source #

An error indicating that an `IO` operation failed because the user does not have sufficient operating system privilege to perform that operation.

isIllegalOperation :: IOError -> Bool Source #

An error indicating that an `IO` operation failed because the operation was not possible. Any computation which returns an `IO` result may fail with `isIllegalOperation`. In some cases, an implementation will not be able to distinguish between the possible error causes. In this case it should fail with `isIllegalOperation`.

isDoesNotExistError :: IOError -> Bool Source #

An error indicating that an `IO` operation failed because one of its arguments does not exist.

isAlreadyExistsError :: IOError -> Bool Source #

An error indicating that an `IO` operation failed because one of its arguments already exists.

mkIOError :: IOErrorType -> String -> Maybe Handle -> Maybe FilePath -> IOError Source #

Construct an `IOError` of the given type where the second argument describes the error location and the third and fourth argument contain the file handle and file path of the file involved in the error if applicable.

tryIOError :: IO a -> IO (Either IOError a) Source #

The construct `tryIOError` `comp` exposes IO errors which occur within a computation, and which are not fully handled.

Non-I/O exceptions are not caught by this variant; to catch all exceptions, use `try` from Control.Exception.

Since: base-4.4.0.0

userError :: String -> IOError Source #

Construct an `IOError` value with a string describing the error. The `fail` method of the `IO` instance of the `Monad` class raises a `userError`, thus:

    instance Monad IO where
      ...
      fail s = ioError (userError s)

type IOError = IOException Source #

The Haskell 2010 type for exceptions in the `IO` monad. Any I/O operation may raise an `IOError` instead of returning a result. For a more general type of exception, including also those that arise in pure code, see `Exception`.

In Haskell 2010, this is an opaque type.

withFilePath :: FilePath -> (CString -> IO a) -> IO a Source #

type EpochTime = CTime Source #

timeout :: Int -> IO a -> IO (Maybe a) Source #

Wrap an `IO` computation to time out and return `Nothing` in case no result is available within `n` microseconds (`1/10^6` seconds). In case a result is available before the timeout expires, `Just a` is returned. A negative timeout interval means "wait indefinitely". When specifying long timeouts, be careful not to exceed `maxBound :: Int`.

    >>> timeout 1000000 (threadDelay 1000 *> pure "finished on time")
    Just "finished on time"

    >>> timeout 10000 (threadDelay 100000 *> pure "finished on time")
    Nothing

The design of this combinator was guided by the objective that `timeout n f` should behave exactly the same as `f` as long as `f` doesn't time out. This means that `f` has the same `myThreadId` it would have without the timeout wrapper. Any exceptions `f` might throw cancel the timeout and propagate further up. It also possible for `f` to receive exceptions thrown to it by another thread.

A tricky implementation detail is the question of how to abort an `IO` computation. This combinator relies on asynchronous exceptions internally. The technique works very well for computations executing inside of the Haskell runtime system, but it doesn't work at all for non-Haskell code. Foreign function calls, for example, cannot be timed out with this combinator simply because an arbitrary C function cannot receive asynchronous exceptions. When `timeout` is used to wrap an FFI call that blocks, no timeout event can be delivered until the FFI call returns, which pretty much negates the purpose of the combinator. In practice, however, this limitation is less severe than it may sound. Standard I/O functions like `hGetBuf`, `hPutBuf`, Network.Socket.accept, or `hWaitForInput` appear to be blocking, but they really don't because the runtime system uses scheduling mechanisms like `select(2)` to perform asynchronous I/O, so it is possible to interrupt standard socket I/O or file I/O using this combinator.

data Void Source #

Uninhabited data type

Since: base-4.8.0.0

#### Instances

Instances details

Eq Void | Since: base-4.8.0.0
Instance details Defined in Data.Void Methods (==) :: Void -> Void -> Bool # (/=) :: Void -> Void -> Bool #
Data Void | Since: base-4.8.0.0
Instance details Defined in Data.Void Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Void -> c Void Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Void Source # toConstr :: Void -> Constr Source # dataTypeOf :: Void -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Void) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Void) Source # gmapT :: (forall b. Data b => b -> b) -> Void -> Void Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Void -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Void -> r Source # gmapQ :: (forall d. Data d => d -> u) -> Void -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> Void -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Void -> m Void Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Void -> m Void Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Void -> m Void Source #
Ord Void | Since: base-4.8.0.0
Instance details Defined in Data.Void Methods compare :: Void -> Void -> Ordering # (<) :: Void -> Void -> Bool # (<=) :: Void -> Void -> Bool # (>) :: Void -> Void -> Bool # (>=) :: Void -> Void -> Bool # max :: Void -> Void -> Void # min :: Void -> Void -> Void #
Read Void | Reading a `Void` value is always a parse error, considering `Void` as a data type with no constructors. Since: base-4.8.0.0
Instance details Defined in Data.Void Methods readsPrec :: Int -> ReadS Void Source # readList :: ReadS [Void] Source # readPrec :: ReadPrec Void Source # readListPrec :: ReadPrec [Void] Source #
Show Void | Since: base-4.8.0.0
Instance details Defined in Data.Void Methods showsPrec :: Int -> Void -> ShowS Source # show :: Void -> String Source # showList :: [Void] -> ShowS Source #
Ix Void | Since: base-4.8.0.0
Instance details Defined in Data.Void Methods range :: (Void, Void) -> [Void] Source # index :: (Void, Void) -> Void -> Int Source # unsafeIndex :: (Void, Void) -> Void -> Int Source # inRange :: (Void, Void) -> Void -> Bool Source # rangeSize :: (Void, Void) -> Int Source # unsafeRangeSize :: (Void, Void) -> Int Source #
Generic Void | Since: base-4.8.0.0
Instance details Defined in Data.Void Associated Types type Rep Void :: Type -> Type Source # Methods from :: Void -> Rep Void x Source # to :: Rep Void x -> Void Source #
Semigroup Void | Since: base-4.9.0.0
Instance details Defined in Data.Void Methods (<>) :: Void -> Void -> Void Source # sconcat :: NonEmpty Void -> Void Source # stimes :: Integral b => b -> Void -> Void Source #
Exception Void | Since: base-4.8.0.0
Instance details Defined in Data.Void Methods toException :: Void -> SomeException Source # fromException :: SomeException -> Maybe Void Source # displayException :: Void -> String Source #
type Rep Void |
Instance details Defined in Data.Void type Rep Void = D1 ('MetaData "Void" "Data.Void" "base" 'False) (V1 :: Type -> Type)