c9efd73bc6b2ef4d4e499812bc2de5acd4379841
[packages/haskell2010.git] / Foreign / Marshal / Utils.hs
1 #if __GLASGOW_HASKELL__ >= 701
2 {-# LANGUAGE Safe #-}
3 #endif
4
5 module Foreign.Marshal.Utils (
6 -- * General marshalling utilities
7
8 -- ** Combined allocation and marshalling
9 --
10 with, -- :: Storable a => a -> (Ptr a -> IO b) -> IO b
11 new, -- :: Storable a => a -> IO (Ptr a)
12
13 -- ** Marshalling of Boolean values (non-zero corresponds to 'True')
14 --
15 fromBool, -- :: Num a => Bool -> a
16 toBool, -- :: Num a => a -> Bool
17
18 -- ** Marshalling of Maybe values
19 --
20 maybeNew, -- :: ( a -> IO (Ptr a))
21 -- -> (Maybe a -> IO (Ptr a))
22 maybeWith, -- :: ( a -> (Ptr b -> IO c) -> IO c)
23 -- -> (Maybe a -> (Ptr b -> IO c) -> IO c)
24 maybePeek, -- :: (Ptr a -> IO b )
25 -- -> (Ptr a -> IO (Maybe b))
26
27 -- ** Marshalling lists of storable objects
28 --
29 withMany, -- :: (a -> (b -> res) -> res) -> [a] -> ([b] -> res) -> res
30
31 -- ** Haskellish interface to memcpy and memmove
32 -- | (argument order: destination, source)
33 --
34 copyBytes, -- :: Ptr a -> Ptr a -> Int -> IO ()
35 moveBytes, -- :: Ptr a -> Ptr a -> Int -> IO ()
36
37 ) where
38 import "base" Foreign.Marshal.Utils