Safe Haskell | None |
---|---|
Language | Haskell2010 |
Foreign.C.Struct
Synopsis
- struct :: StrName -> StrSize -> [(MemName, MemType, MemPeek, MemPoke)] -> [DerivClass] -> DecsQ
- type StrName = String
- type StrSize = Integer
- type MemName = String
- type MemType = Name
- type MemPeek = ExpQ
- type MemPoke = ExpQ
- type DerivClass = Name
- structPrim :: StrName -> FunCopy -> FunFree -> [DerivClass] -> DecsQ
- type FunCopy = Name
- type FunFree = Name
STRUCT
struct :: StrName -> StrSize -> [(MemName, MemType, MemPeek, MemPoke)] -> [DerivClass] -> DecsQ Source #
Example
struct Foo ${size Foo} [ ("x", ''CInt, [| {poke Foo, x} |]), ("y", ''CInt, [| {poke Foo, y} |]) ] [''Show, ''Read, ''Eq, ''Ord, ''Bounded]
type DerivClass = Name Source #
STRUCT WITH PRIMITIVE MONAD
structPrim :: StrName -> FunCopy -> FunFree -> [DerivClass] -> DecsQ Source #
Example
foreign import ccall "foo_copy" c_foo_copy :: Ptr Foo -> IO (Ptr Foo) foreign import ccall "foo_free" c_foo_free :: Ptr Foo -> IO () structPrim Foo 'c_foo_copy 'c_foo_free [''Show]