Copyright | (c) Mateusz Kłoczko 2016 |
---|---|
License | MIT |
Maintainer | mateusz.p.kloczko@gmail.com |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Foreign.Storable.Generic.Internal
Description
- class GStorable' f where
- class GStorable a where
- internalSizeOf :: forall f p. GStorable' f => f p -> Int
- internalAlignment :: forall f p. GStorable' f => f p -> Alignment
- internalPeekByteOff :: forall f p b. GStorable' f => Ptr b -> Offset -> IO (f p)
- internalPokeByteOff :: forall f p b. GStorable' f => Ptr b -> Offset -> f p -> IO ()
- internalOffsets :: forall f p. GStorable' f => f p -> [Offset]
Documentation
class GStorable' f where Source #
Minimal complete definition
gpeekByteOff', gpokeByteOff', gnumberOf', glistSizeOf', glistAlignment'
Methods
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.
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 () |
Arguments
:: f a | GHC.Generic information about a given type/struct. |
-> Int | Size. |
Calculates the number of type's/struct's fields.
Arguments
:: f a | GHC.Generic information about a given type/struct. |
-> [Size] | List of sizes. |
Calculates the sizes of type's/struct's fields.
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 # | |
GStorable a => GStorable' (K1 * i a) Source # | |
(GStorable' f, GStorable' g) => GStorable' ((:*:) * f g) Source # | |
GStorable' f => GStorable' (M1 * i t f) 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
Arguments
:: a | Element of a given type. Can be undefined. |
-> Int | Size. |
Calculate the size of the type.
Arguments
:: (Generic a, GStorable' (Rep a)) | |
=> a | Element of a given type. Can be undefined. |
-> Int | Size. |
Calculate the size of the type.
Arguments
:: a | Element of a given type. Can be undefined |
-> Int | Alignment. |
Calculate the alignment of the type.
Arguments
:: (Generic a, GStorable' (Rep a)) | |
=> a | Element of a given type. Can be undefined |
-> Int | Alignment. |
Calculate the alignment of the type.
Read the variable from a given pointer.
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.
Write the variable to a pointer.
Arguments
:: (Generic a, GStorable' (Rep a)) | |
=> Ptr b | Pointer to the variable. |
-> Int | Offset. |
-> a | The variable |
-> IO () |
Write the variable to a pointer.
Arguments
:: GStorable' f | |
=> f p | Generic representation |
-> Int | Resulting size |
Calculates the size of generic data-type.
Arguments
:: GStorable' f | |
=> f p | Generic representation |
-> Alignment | Resulting alignment |
Calculates the alignment of generic data-type.
Arguments
:: GStorable' f | |
=> Ptr b | Pointer to peek |
-> Offset | Offset |
-> IO (f p) | Resulting generic representation |
View the variable under a pointer, with offset.
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