Safe Haskell | Safe |
---|

- with :: Storable a => a -> (Ptr a -> IO b) -> IO b
- new :: Storable a => a -> IO (Ptr a)
- fromBool :: Num a => Bool -> a
- toBool :: (Eq a, Num a) => a -> Bool
- maybeNew :: (a -> IO (Ptr b)) -> Maybe a -> IO (Ptr b)
- maybeWith :: (a -> (Ptr b -> IO c) -> IO c) -> Maybe a -> (Ptr b -> IO c) -> IO c
- maybePeek :: (Ptr a -> IO b) -> Ptr a -> IO (Maybe b)
- withMany :: (a -> (b -> res) -> res) -> [a] -> ([b] -> res) -> res
- copyBytes :: Ptr a -> Ptr a -> Int -> IO ()
- moveBytes :: Ptr a -> Ptr a -> Int -> IO ()

# General marshalling utilities

## Combined allocation and marshalling

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

executes the computation `with`

val f`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.

## Marshalling of Boolean values (non-zero corresponds to `True`

)

## Marshalling of Maybe values

## Marshalling lists of storable objects

withMany :: (a -> (b -> res) -> res) -> [a] -> ([b] -> res) -> res

Replicates a `withXXX`

combinator over a list of objects, yielding a list of
marshalled objects

## Haskellish interface to memcpy and memmove

(argument order: destination, source)