derive-storable-0.1.2.0: Derive Storable instances with GHC.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' Source #

Arguments

:: [Int]

List of fields' offsets for the type/struct.

-> Int

The index. Used to obtain the correct offset

-> Ptr b

The pointer to the type/struct.

-> Int

Global offset.

-> IO (f a)

The result, wrapped in GHC.Generic metadata. | Write the element at a given offset. Additional information about the offests of the subfields are needed.

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

gpokeByteOff' Source #

Arguments

:: [Int]

List of fields' offsets for the type/struct.

-> Int

The index. Used to obtain the correct offset.

-> Ptr b

The pointer to the type/struct.

-> Int

Global offset.

-> f a

The element to write, wrapped in GHC.Generic metadata.

-> IO () 

gnumberOf' Source #

Arguments

:: f a

GHC.Generic information about a given type/struct.

-> Int

Size.

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

glistSizeOf' Source #

Arguments

:: f a

GHC.Generic information about a given type/struct.

-> [Size]

List of sizes.

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

glistAlignment' Source #

Arguments

:: f a

GHC.Generic information about a given type/struct.

-> [Alignment]

List of alignments.

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

Instances

GStorable' (U1 *) Source # 

Methods

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

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

gnumberOf' :: U1 * a -> Int Source #

glistSizeOf' :: U1 * a -> [Size] Source #

glistAlignment' :: U1 * a -> [Alignment] Source #

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 Source #

Arguments

:: a

Element of a given type. Can be undefined.

-> Int

Size.

Calculate the size of the type.

gsizeOf Source #

Arguments

:: (Generic a, GStorable' (Rep a)) 
=> a

Element of a given type. Can be undefined.

-> Int

Size.

Calculate the size of the type.

galignment Source #

Arguments

:: a

Element of a given type. Can be undefined

-> Int

Alignment.

Calculate the alignment of the type.

galignment Source #

Arguments

:: (Generic a, GStorable' (Rep a)) 
=> a

Element of a given type. Can be undefined

-> Int

Alignment.

Calculate the alignment of the type.

gpeekByteOff Source #

Arguments

:: Ptr b

Pointer to the variable

-> Int

Offset

-> IO a

Returned variable.

Read the variable from a given pointer.

gpeekByteOff Source #

Arguments

:: (Generic a, GStorable' (Rep a)) 
=> Ptr b

Pointer to the variable

-> Int

Offset

-> IO a

Returned variable.

Read the variable from a given pointer.

gpokeByteOff Source #

Arguments

:: Ptr b

Pointer to the variable.

-> Int

Offset.

-> a

The variable

-> IO () 

Write the variable to a pointer.

gpokeByteOff Source #

Arguments

:: (Generic a, GStorable' (Rep a)) 
=> Ptr b

Pointer to the variable.

-> Int

Offset.

-> a

The variable

-> IO () 

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