Skip to content

maurer/c-storable-deriving

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

c-storable-deriving

This library is intended to make generating C-like storable instances from datatypes easy.

Example

{-# LANGUAGE DeriveGeneric, DeriveAnyClass #-}

import GHC.Generics (Generic(..))
import Foreign (Storable(..))
import Foreign.CStorable (CStorable(..))

-- | a two-dimensional point.
-- Compatible with both OSX's @CGPoint@ and Window's @POINT@.
data Point = Point
 { x :: Double
 , y :: Double
 } deriving (Generic, CStorable)

instance Storable Point where
 peek      = cPeek
 poke      = cPoke
 alignment = cAlignment
 sizeOf    = cSizeOf

See the haddocks for further details: Foreign.CStorable

About

Derivation of C-like Storable Instances

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published