Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Helper functions. This module is internal and should not be used in production code.
- withOptionalCString :: Maybe String -> (CString -> IO ()) -> IO ()
- listEntryNotNull :: (Monad m, MonadIO m) => StateT (Ptr (Ptr a)) m Bool
- loopCList :: (Monad m, MonadIO m) => (Ptr a -> m ()) -> Ptr (Ptr a) -> m ()
- copyToCList :: (Num size, Enum size) => (CSize -> IO list) -> (a -> IO element) -> (list -> size -> element -> IO ()) -> [a] -> IO list
- concatPaths :: [FilePath] -> FilePath
- arrayRange :: (Num a, Integral a, Enum a) => a -> [a]
Interoperation with C API
withOptionalCString :: Maybe String -> (CString -> IO ()) -> IO () Source
withOptionalCString
str action
, if str
is Nothing
, action
is not
invoked, otherwise behaves like withCString
.
listEntryNotNull :: (Monad m, MonadIO m) => StateT (Ptr (Ptr a)) m Bool Source
Checks if the pointer in state points to non-null location.
loopCList :: (Monad m, MonadIO m) => (Ptr a -> m ()) -> Ptr (Ptr a) -> m () Source
loopCArray
action list
calls action
over each element of list
that
is C array with NULL signifying end of array.
:: (Num size, Enum size) | |
=> (CSize -> IO list) | List creator. |
-> (a -> IO element) | Conversion function. |
-> (list -> size -> element -> IO ()) | Set element function. |
-> [a] | Elements. |
-> IO list |
Copies converted list of elements to new C array.
Other helpers
concatPaths :: [FilePath] -> FilePath Source
Concatenates list of paths, separating entries with appropriate character.
arrayRange :: (Num a, Integral a, Enum a) => a -> [a] Source
Generates array indices for array of specified length.