(Ptr a -> IO b) -> IO b

withStorableArray :: StorableArray i e -> (Ptr e -> IO a) -> IO a
array Data.Array.Storable, array Data.Array.Storable.Safe
The pointer to the array contents is obtained by withStorableArray. The idea is similar to ForeignPtr (used internally here). The pointer should be used only during execution of the IO action retured by the function passed as argument to withStorableArray.
withBuffer :: Buffer e -> (Ptr e -> IO a) -> IO a
base GHC.IO.Buffer
allocaBytes :: Int -> (Ptr a -> IO b) -> IO b
base Foreign.Marshal.Alloc
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.
withForeignPtr :: ForeignPtr a -> (Ptr a -> IO b) -> IO b
base Foreign.ForeignPtr
This is a way to look at the pointer living inside a foreign object. This function takes a function which is applied to that pointer. The resulting IO action is then executed. The foreign object is kept alive at least during the whole action, even if it is not used directly inside. Note that it is not safe to return the pointer from the action and use it after the action completes. All uses of the pointer should be inside the withForeignPtr bracket. The reason for this unsafeness is the same as for unsafeForeignPtrToPtr below: the finalizer may run earlier than expected, because the compiler can only track usage of the ForeignPtr object, not a Ptr object made from it. This function is normally used for marshalling data to or from the object pointed to by the ForeignPtr, using the operations from the Storable class.
withRawBuffer :: RawBuffer e -> (Ptr e -> IO a) -> IO a
base GHC.IO.Buffer
alloca :: Storable a => (Ptr a -> IO b) -> IO b
base Foreign.Marshal.Alloc
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.
allocaBytesAligned :: Int -> Int -> (Ptr a -> IO b) -> IO b
base Foreign.Marshal.Alloc
maybeWith :: (a -> (Ptr b -> IO c) -> IO c) -> (Maybe a -> (Ptr b -> IO c) -> IO c)
base Foreign.Marshal.Utils
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
base Foreign.Marshal.Utils
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.
allocaArray :: Storable a => Int -> (Ptr a -> IO b) -> IO b
base Foreign.Marshal.Array
Temporarily allocate space for the given number of elements (like Foreign.Marshal.Alloc.alloca, but for multiple elements).
allocaArray0 :: Storable a => Int -> (Ptr a -> IO b) -> IO b
base Foreign.Marshal.Array
Like allocaArray, but add an extra position to hold a special termination element.
withArray :: Storable a => [a] -> (Ptr a -> IO b) -> IO b
base Foreign.Marshal.Array
Temporarily store a list of storable values in memory (like Foreign.Marshal.Utils.with, but for multiple elements).
unsafeUseAsCString :: ByteString -> (CString -> IO a) -> IO a
bytestring Data.ByteString.Unsafe
O(1) construction Use a ByteString with a function requiring a CString. This function does zero copying, and merely unwraps a ByteString to appear as a CString. It is unsafe in two ways: * After calling this function the CString shares the underlying byte buffer with the original ByteString. Thus modifying the CString, either in C, or using poke, will cause the contents of the ByteString to change, breaking referential transparency. Other ByteStrings created by sharing (such as those produced via take or drop) will also reflect these changes. Modifying the CString will break referential transparency. To avoid this, use useAsCString, which makes a copy of the original ByteString. * CStrings are often passed to functions that require them to be null-terminated. If the original ByteString wasn't null terminated, neither will the CString be. It is the programmers responsibility to guarantee that the ByteString is indeed null terminated. If in doubt, use useAsCString.
useAsCString :: ByteString -> (CString -> IO a) -> IO a
bytestring Data.ByteString, bytestring Data.ByteString.Char8
O(n) construction Use a ByteString with a function requiring a null-terminated CString. The CString will be freed automatically. This is a memcpy(3).
withPolygonStipple :: PolygonStipple s => s -> (Ptr GLubyte -> IO a) -> IO a
OpenGL Graphics.Rendering.OpenGL.GL.Polygons
withNURBSObj :: a -> (NURBSObj -> IO a) -> IO a
OpenGL Graphics.Rendering.OpenGL.GLU.NURBS
withArray0 :: Storable a => a -> [a] -> (Ptr a -> IO b) -> IO b
base Foreign.Marshal.Array
Like withArray, but a terminator indicates
withFilePath :: RawFilePath -> (CString -> IO a) -> IO a
unix System.Posix.ByteString.FilePath
withCAString :: String -> (CString -> IO a) -> IO a
base Foreign.C.String
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.
withCString :: String -> (CString -> IO a) -> IO a
base Foreign.C.String
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.

Show more results