marshal-contt-0.1.0.0: A ContT-based wrapper for Haskell-to-C marshalling functions.

Copyright(c) Alexis Williams 2019
LicenseMPL-2.0
Maintaineralexis@typedr.at
Stabilityprovisional
Portabilityportable
Safe HaskellSafe
LanguageHaskell2010

Foreign.Marshal.ContT

Contents

Description

This library wraps the standard base bracketed allocation primitives (along with those from ByteString) in a ContT-based interface to ease the chaining of complex marshalling operations.

Synopsis

alloca

alloca :: Storable a => ContT r IO (Ptr a) Source #

alloca is a continuation that provides access to a pointer into a temporary block of memory sufficient to hold values of type a.

allocaWith :: Storable a => a -> ContT r IO (Ptr a) Source #

allocaWith a is a continuation that provides access to a pointer into a temporary block of memory containing a.

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

allocaBytes n is a continuation that provides access to a pointer into a temporary block of memory sufficient to hold n bytes, with machine-standard alignment.

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

allocaBytesAligned n a is a continuation that provides access to a pointer into a temporary block of memory sufficient to hold n bytes, with a-byte alignment.

calloc

calloc :: forall r a. Storable a => ContT r IO (Ptr a) Source #

calloc is a continuation that provides access to a pointer into a temporary block of zeroed memory sufficient to hold values of type a.

callocBytes :: Int -> ContT r IO (Ptr a) Source #

callocBytes n is a continuation that provides access to a pointer into a temporary block of zeroed memory sufficient to hold n bytes, with machine-standard alignment.

allocaArray

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

allocaArray @a n is a continuation that provides access to a pointer into a temporary block of memory sufficient to hold n values of type a.

allocaArrayWith :: (Traversable t, Storable a) => t a -> ContT r IO (Ptr a) Source #

allocaArrayWith xs is a continuation that provides access to a pointer into a temporary block of memory containing the values of xs.

allocaArray0 :: Storable a => Int -> ContT r IO (Ptr a) Source #

allocaArray0 @a n is a continuation that provides access to a pointer into a temporary block of memory sufficient to hold n values of type a, along with a final terminal element.

allocaArrayWith0 :: (Traversable t, Storable a) => t a -> a -> ContT r IO (Ptr a) Source #

allocaArrayWith xs end is a continuation that provides access to a pointer into a temporary block of memory containing the values of xs, terminated with end.

callocArray

callocArray :: Storable a => Int -> ContT r IO (Ptr a) Source #

callocArray0 @a n is a continuation that provides access to a pointer into a temporary block of zeroed memory sufficient to hold n values of type a.

callocArray0 :: Storable a => Int -> ContT r IO (Ptr a) Source #

callocArray0 @a n is a continuation that provides access to a pointer into a temporary block of zeroed memory sufficient to hold n values of type a, along with a final terminal element.

withForeignPtr

withForeignPtr :: ForeignPtr a -> ContT r IO (Ptr a) Source #

withForeignPtr ptr is a continuation that provides safe access to the backing pointer of ptr.

ToCString

class ToCString a where Source #

ToCString a is a class for types a that can be encoded into CStrings.

Methods

withCString :: a -> ContT r IO CString Source #

withCString a is a continuation that provides access to a as a CString.

withCStringLen :: a -> ContT r IO CStringLen Source #

withCStringLen a is a continuation that provides access to a as a CStringLen.