derive-storable-0.1.0.0: Deriving Storable instances using generics.

Copyright(c) Mateusz Kłoczko, 2016
LicenseMIT
Maintainermateusz.p.kloczko@gmail.com
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Foreign.Storable.Generic.Internal

Description

 

Synopsis

Documentation

class GStorable' f where Source #

Methods

gpeekByteOff' :: [Int] -> Int -> Ptr b -> Int -> IO (f a) Source #

Read the element at a given offset. Additional information about the offests of the subfields are needed.

gpokeByteOff' :: [Int] -> Int -> Ptr b -> Int -> f a -> IO () Source #

gnumberOf' :: f a -> Int Source #

Calculates the number of type's/struct's fields.

glistSizeOf' :: f a -> [Size] Source #

Calculates the sizes of type's/struct's fields.

glistAlignment' :: f a -> [Alignment] Source #

Calculates the alignments of type's/struct's fields.

Instances

GStorable a => GStorable' (K1 i a) Source # 

Methods

gpeekByteOff' :: [Int] -> Int -> Ptr b -> Int -> IO (K1 i a a) Source #

gpokeByteOff' :: [Int] -> Int -> Ptr b -> Int -> K1 i a a -> IO () Source #

gnumberOf' :: K1 i a a -> Int Source #

glistSizeOf' :: K1 i a a -> [Size] Source #

glistAlignment' :: K1 i a a -> [Alignment] Source #

(GStorable' f, GStorable' g) => GStorable' ((:*:) f g) Source # 

Methods

gpeekByteOff' :: [Int] -> Int -> Ptr b -> Int -> IO ((f :*: g) a) Source #

gpokeByteOff' :: [Int] -> Int -> Ptr b -> Int -> (f :*: g) a -> IO () Source #

gnumberOf' :: (f :*: g) a -> Int Source #

glistSizeOf' :: (f :*: g) a -> [Size] Source #

glistAlignment' :: (f :*: g) a -> [Alignment] Source #

GStorable' f => GStorable' (M1 i t f) Source # 

Methods

gpeekByteOff' :: [Int] -> Int -> Ptr b -> Int -> IO (M1 i t f a) Source #

gpokeByteOff' :: [Int] -> Int -> Ptr b -> Int -> M1 i t f a -> IO () Source #

gnumberOf' :: M1 i t f a -> Int Source #

glistSizeOf' :: M1 i t f a -> [Size] Source #

glistAlignment' :: M1 i t f a -> [Alignment] Source #

class GStorable a where Source #

The class uses the default Generic based implementations to provide Storable instances for types made from primitive types. Does not work on Algebraic Data Types with more than one constructor.

Methods

gsizeOf :: a -> Int Source #

Calculate the size of the type.

gsizeOf :: (Generic a, GStorable' (Rep a)) => a -> Int Source #

Calculate the size of the type.

galignment :: a -> Int Source #

Calculate the alignment of the type.

galignment :: (Generic a, GStorable' (Rep a)) => a -> Int Source #

Calculate the alignment of the type.

gpeekByteOff :: Ptr b -> Int -> IO a Source #

Read the variable from a given pointer.

gpeekByteOff :: (Generic a, GStorable' (Rep a)) => Ptr b -> Int -> IO a Source #

Read the variable from a given pointer.

gpokeByteOff :: Ptr b -> Int -> a -> IO () Source #

Write the variable to a pointer.

gpokeByteOff :: (Generic a, GStorable' (Rep a)) => Ptr b -> Int -> a -> IO () Source #

Write the variable to a pointer.

internalSizeOf Source #

Arguments

:: GStorable' f 
=> f p

Generic representation

-> Int

Resulting size

Calculates the size of generic data-type.

internalAlignment Source #

Arguments

:: GStorable' f 
=> f p

Generic representation

-> Alignment

Resulting alignment

Calculates the alignment of generic data-type.

internalPeekByteOff Source #

Arguments

:: GStorable' f 
=> Ptr b

Pointer to peek

-> Offset

Offset

-> IO (f p)

Resulting generic representation

View the variable under a pointer, with offset.

internalPokeByteOff Source #

Arguments

:: GStorable' f 
=> Ptr b

Pointer to write to

-> Offset

Offset

-> f p

Written generic representation

-> IO () 

Write the variable under the pointer, with offset.

internalOffsets :: forall f p. GStorable' f => f p -> [Offset] Source #

Obtain the list of offsets