allocated-processor-0.0.2: Functional combinators for monadic actions that require allocation and de-allocation

Foreign.ForeignPtrWrap

Synopsis

Documentation

createForeignPtr :: FunPtr (Ptr a -> IO ()) -> IO (Ptr a) -> IO (ForeignPtr a)Source

A wrapper for newForeignPtr that handles nullPtrs, and can be chained to an IO Ptr creator.

Example usage:

 myPtrCreator = (createForeignPtr deallocFunc) . allocFunc

where, allocFunc :: a->b->c->...-> IO (Ptr z)

checkPtr :: IO (Ptr a) -> IO (Ptr a)Source

Fails if the ptr is nullPtr

errorName :: String -> IO a -> IO aSource

Names a failure