Google

>
 Haskell Core Libraries (base package)ParentContentsIndex
Foreign.Marshal.Utils
Portability portable
Stability provisional
Maintainer ffi@haskell.org
Description
Utilities for primitive marshaling
Synopsis
with :: (Storable a) => a -> (Ptr a -> IO b) -> IO b
new :: (Storable a) => a -> IO (Ptr a)
fromBool :: (Num a) => Bool -> a
toBool :: (Num a) => a -> Bool
maybeNew :: (a -> IO (Ptr a)) -> Maybe a -> IO (Ptr a)
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 ()
withObject :: (Storable a) => a -> (Ptr a -> IO b) -> IO b
General marshalling utilities
Combined allocation and marshalling
with :: (Storable a) => a -> (Ptr a -> IO b) -> IO b

Allocate temporary storage for a value and marshal it into this storage

  • see the life time constraints imposed by alloca

new :: (Storable a) => a -> IO (Ptr a)
Allocate storage for a value and marshal it into this storage
Marshalling of Boolean values (non-zero corresponds to True)
fromBool :: (Num a) => Bool -> a
Convert a Haskell Bool to its numeric representation
toBool :: (Num a) => a -> Bool
Convert a Boolean in numeric representation to a Haskell value
Marshalling of Maybe values
maybeNew :: (a -> IO (Ptr a)) -> Maybe a -> IO (Ptr a)

Allocate storage and marshall a storable value wrapped into a Maybe

maybeWith :: (a -> (Ptr b -> IO c) -> IO c) -> Maybe a -> (Ptr b -> IO c) -> IO c
Converts a withXXX combinator into one marshalling a value wrapped into a Maybe
maybePeek :: (Ptr a -> IO b) -> Ptr a -> IO (Maybe b)
Convert a peek combinator into a one returning Nothing if applied to a nullPtr
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)
copyBytes :: Ptr a -> Ptr a -> Int -> IO ()
Copies the given number of bytes from the second area (source) into the first (destination); the copied areas may not overlap
moveBytes :: Ptr a -> Ptr a -> Int -> IO ()
Copies the given number of elements from the second area (source) into the first (destination); the copied areas may overlap
DEPRECATED FUNCTIONS (don't use; they may disappear at any time)
withObject :: (Storable a) => a -> (Ptr a -> IO b) -> IO b
Produced by Haddock version 0.4