type CString = Ptr CChar { } #
C string (null-terminated).
type CStringLen = (Ptr CChar, Int) { } #
C string with length.
newtype CChar { } #
CChar Int8
C signed char.
newtype CSChar { } #
CSChar Int8
C signed char (explicit).
newtype CUChar { } #
CUChar Word8
C unsigned char.
newtype CShort { } #
CShort Int16
C short.
newtype CUShort { } #
CUShort Word16
C unsigned short.
newtype CInt { } #
CInt Int32
C int.
newtype CUInt { } #
CUInt Word32
C unsigned int.
newtype CLong { } #
CLong Int64
C long.
newtype CULong { } #
CULong Word64
C unsigned long.
newtype CLLong { } #
CLLong Int64
C long long.
newtype CULLong { } #
CULLong Word64
C unsigned long long.
newtype CFloat { } #
CFloat Float
C float.
newtype CDouble { } #
CDouble Double
C double.
newtype CSize { } #
CSize Word64
C size_t.
newtype CSSize { } #
CSSize Int64
C ssize_t.
newtype CPtrdiff { } #
CPtrdiff Int64
C ptrdiff_t.
newtype CIntPtr { } #
CIntPtr Int64
C intptr_t.
newtype CUIntPtr { } #
CUIntPtr Word64
C uintptr_t.
newtype CBool { } #
CBool Word8
C bool.
newtype Errno { } #
Errno CInt
C errno value.
type FinalizerPtr a = FunPtr ((Ptr a) -> IO ()) { } #
class Storable a { } #

Methods

sizeOf :: a -> Int
alignment :: a -> Int
peek :: (Ptr a) -> IO a
poke :: (Ptr a) -> a -> IO ()
peekByteOff :: (Ptr b) -> Int -> IO a
pokeByteOff :: (Ptr b) -> Int -> a -> IO ()
peekElemOff :: (Ptr a) -> Int -> IO a
pokeElemOff :: (Ptr a) -> Int -> a -> IO ()
Class for types that can be stored in memory.
class CCallable a { } #
Constraint for types callable from C.
class CReturnable a { } #
Constraint for types returnable to C.
nullPtr :: Ptr a { } #
nullFunPtr :: FunPtr a { } #
The null function pointer.
castPtr :: (Ptr a) -> Ptr b { } #
Cast pointer to different type.
castFunPtr :: (FunPtr a) -> FunPtr b { } #
Cast function pointer to different type.
plusPtr :: (Ptr a) -> Int -> Ptr b { } #
Advance pointer by offset bytes.
minusPtr :: (Ptr a) -> (Ptr b) -> Int { } #
Compute byte difference between pointers.
alignPtr :: (Ptr a) -> Int -> Ptr a { } #
Align pointer to alignment boundary.
newForeignPtr :: (FinalizerPtr a) -> (Ptr a) -> IO (ForeignPtr a) { } #
Create foreign pointer with finalizer.
newForeignPtr_ :: (Ptr a) -> IO (ForeignPtr a) { } #
Create foreign pointer without finalizer.
withForeignPtr :: (ForeignPtr a) -> ((Ptr a) -> IO b) -> IO b { } #
Execute action with foreign pointer.
touchForeignPtr :: (ForeignPtr a) -> IO () { } #
Keep foreign pointer alive.
castForeignPtr :: (ForeignPtr a) -> ForeignPtr b { } #
Cast foreign pointer to different type.
mallocForeignPtr :: (Storable a) => IO (ForeignPtr a) { } #
Allocate foreign memory for Storable value.
mallocForeignPtrBytes :: Int -> IO (ForeignPtr a) { } #
Allocate foreign memory of given size.
mallocForeignPtrArray :: (Storable a) => Int -> IO (ForeignPtr a) { } #
Allocate foreign array.
addForeignPtrFinalizer :: (FinalizerPtr a) -> (ForeignPtr a) -> IO () { } #
Add finalizer to foreign pointer.
finalizeForeignPtr :: (ForeignPtr a) -> IO () { } #
Run finalizers immediately.
malloc :: (Storable a) => IO (Ptr a) { } #
Allocate memory for a Storable value.
mallocBytes :: Int -> IO (Ptr a) { } #
Allocate memory of given size.
mallocArray :: (Storable a) => Int -> IO (Ptr a) { } #
Allocate array of Storable values.
calloc :: (Storable a) => IO (Ptr a) { } #
Allocate zero-initialized memory.
callocBytes :: Int -> IO (Ptr a) { } #
Allocate zero-initialized bytes.
callocArray :: (Storable a) => Int -> IO (Ptr a) { } #
Allocate zero-initialized array.
realloc :: (Storable b) => (Ptr a) -> IO (Ptr b) { } #
Resize allocated memory.
reallocBytes :: (Ptr a) -> Int -> IO (Ptr a) { } #
Resize to given size.
reallocArray :: (Storable a) => (Ptr a) -> Int -> IO (Ptr a) { } #
Resize array.
free :: (Ptr a) -> IO () { } #
Free allocated memory.
freeBytes :: (Ptr a) -> IO () { } #
Free allocated bytes.
mallocPinned :: (Storable a) => IO (Ptr a) { } #
Allocate pinned memory (won't be moved by GC).
mallocPinnedBytes :: Int -> IO (Ptr a) { } #
Allocate pinned bytes.
mallocPinnedArray :: (Storable a) => Int -> IO (Ptr a) { } #
Allocate pinned array.
mallocAligned :: Int -> Int -> IO (Ptr a) { } #
Allocate with specific alignment.
isPinned :: (Ptr a) -> IO Bool { } #
Check if memory is pinned.
alloca :: (Storable a) => ((Ptr a) -> IO b) -> IO b { } #
Allocate temporary memory for Storable.
allocaBytes :: Int -> ((Ptr a) -> IO b) -> IO b { } #
Allocate temporary bytes.
allocaArray :: (Storable a) => Int -> ((Ptr a) -> IO b) -> IO b { } #
Allocate temporary array.
with :: (Storable a) => a -> ((Ptr a) -> IO b) -> IO b { } #
Allocate and initialize with value.
withArray :: (Storable a) => [a] -> ((Ptr a) -> IO b) -> IO b { } #
Allocate and initialize array.
withArrayLen :: (Storable a) => [a] -> (Int -> (Ptr a) -> IO b) -> IO b { } #
Allocate array with length.
withArray0 :: (Storable a) => a -> [a] -> ((Ptr a) -> IO b) -> IO b { } #
Allocate null-terminated array.
copyArray :: (Storable a) => (Ptr a) -> (Ptr a) -> Int -> IO () { } #
Copy array elements.
moveArray :: (Storable a) => (Ptr a) -> (Ptr a) -> Int -> IO () { } #
Move array elements (may overlap).
lengthArray0 :: (Storable a, Eq a) => a -> (Ptr a) -> IO Int { } #
Find length of null-terminated array.
advancePtr :: (Storable a) => (Ptr a) -> Int -> Ptr a { } #
Advance pointer by element count.
peekArray :: (Storable a) => Int -> (Ptr a) -> IO [a] { } #
Read array from memory.
peekArray0 :: (Storable a, Eq a) => a -> (Ptr a) -> IO [a] { } #
Read null-terminated array.
pokeArray :: (Storable a) => (Ptr a) -> [a] -> IO () { } #
Write array to memory.
pokeArray0 :: (Storable a) => a -> (Ptr a) -> [a] -> IO () { } #
Write null-terminated array.
newArray :: (Storable a) => [a] -> IO (Ptr a) { } #
Allocate and initialize new array.
newArray0 :: (Storable a) => a -> [a] -> IO (Ptr a) { } #
Allocate null-terminated array.
peekCString :: CString -> IO String { } #
Read C string to Haskell String.
peekCStringLen :: CStringLen -> IO String { } #
Read C string with length.
newCString :: String -> IO CString { } #
Create new C string.
newCStringLen :: String -> IO CStringLen { } #
Create C string with length.
withCString :: String -> (CString -> IO a) -> IO a { } #
Execute with temporary C string.
withCStringLen :: String -> (CStringLen -> IO a) -> IO a { } #
Execute with temporary C string and length.
castCharToCChar :: Char -> CChar { } #
Convert Char to CChar.
castCCharToChar :: CChar -> Char { } #
Convert CChar to Char.
newStablePtr :: a -> IO (StablePtr a) { } #
Create stable pointer.
deRefStablePtr :: (StablePtr a) -> IO a { } #
Dereference stable pointer.
freeStablePtr :: (StablePtr a) -> IO () { } #
Free stable pointer.
castStablePtrToPtr :: (StablePtr a) -> Ptr () { } #
Cast stable pointer to raw pointer.
castPtrToStablePtr :: (Ptr ()) -> StablePtr a { } #
Cast raw pointer to stable pointer.
wrapFunPtr :: a -> IO (FunPtr a) { } #
freeFunPtr :: (FunPtr a) -> IO () { } #
Free function pointer wrapper.
dynamicFunPtr :: (FunPtr a) -> a { } #
Call function pointer dynamically.
getErrno :: IO Errno { } #
Get current errno.
resetErrno :: IO () { } #
Reset errno to zero.
throwErrno :: String -> IO a { } #
Throw IO error based on errno.
throwErrnoIf :: (a -> Bool) -> String -> (IO a) -> IO a { } #
Throw if predicate holds.
throwErrnoIfMinus1 :: (Eq a, Num a) => String -> (IO a) -> IO a { } #
Throw if result is -1.
throwErrnoIfNull :: String -> (IO (Ptr a)) -> IO (Ptr a) { } #
Throw if result is null.
throwErrnoPath :: String -> FilePath -> IO a { } #
Throw with path information.
throwErrnoPathIf :: (a -> Bool) -> String -> FilePath -> (IO a) -> IO a { } #
Throw with path if predicate holds.
importC :: String -> a { } #
Import C function (compile-time).
exportC :: String -> a { } #
Export Haskell function to C (compile-time).
unsafePerformIO :: (IO a) -> a { } #
Perform IO unsafely.
unsafeInterleaveIO :: (IO a) -> IO a { } #
Interleave IO lazily.
unsafeDupablePerformIO :: (IO a) -> a { } #
Perform IO unsafely (may be duplicated).
unsafeLocalState :: (IO a) -> a { } #
Create local mutable state.