c-struct-0.1.1.1: To make a wrapper for struct of C language
Safe HaskellNone
LanguageHaskell2010

Foreign.C.Struct

Synopsis

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]
 

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]