Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- struct :: StrName -> StrSize -> StrAlgn -> [(MemName, MemType, MemPeek, MemPoke)] -> [DerivClass] -> DecsQ
- type StrName = String
- type StrSize = Integer
- type StrAlgn = 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 -> StrAlgn -> [(MemName, MemType, MemPeek, MemPoke)] -> [DerivClass] -> DecsQ Source #
Example
struct "Foo" ${size Foo} #{alignment Foo} [ ("x", ''CInt, [| #{peek Foo, x} |], [| #{poke Foo, x} |]), ("y", ''CInt, [| #{peek Foo, y} |], [| #{poke Foo, y} |]) ] [''Show, ''Read, ''Eq, ''Ord, ''Bounded, ''Storable]
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]