derive-storable-0.3.1.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 () 

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

Instances details
GStorable' (U1 :: Type -> Type) Source # 
Instance details

Defined in Foreign.Storable.Generic.Internal

Methods

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

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

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

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

Storable a => GStorable' (K1 i a :: Type -> Type) Source # 
Instance details

Defined in Foreign.Storable.Generic.Internal

Methods

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

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

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

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

(KnownNat (NoFields f), KnownNat (NoFields g), GStorable' f, GStorable' g) => GStorable' (f :*: g) Source # 
Instance details

Defined in Foreign.Storable.Generic.Internal

Methods

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

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

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

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

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

Defined in Foreign.Storable.Generic.Internal

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 #

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. Sum types work with sumtypes cabal flag enabled - or just with -DGSTORABLE_SUMTYPES cpp flag.

Minimal complete definition

Nothing

Methods

gsizeOf Source #

Arguments

:: a

Element of a given type. Can be undefined.

-> Int

Size.

Calculate the size of the type.

default gsizeOf :: (ConstraintsSize a, GStorableChoice a) => a -> Int Source #

galignment Source #

Arguments

:: a

Element of a given type. Can be undefined

-> Int

Alignment.

Calculate the alignment of the type.

default galignment :: (ConstraintsAlignment a, GStorableChoice a) => a -> Int Source #

gpeekByteOff Source #

Arguments

:: Ptr b

Pointer to the variable

-> Int

Offset

-> IO a

Returned variable.

Read the variable from a given pointer.

default gpeekByteOff :: (GStorableChoice a, ConstraintsPeek a) => Ptr b -> Int -> IO a Source #

gpokeByteOff Source #

Arguments

:: Ptr b

Pointer to the variable.

-> Int

Offset.

-> a

The variable

-> IO () 

Write the variable to a pointer.

default gpokeByteOff :: (GStorableChoice a, ConstraintsPoke a) => Ptr b -> Int -> a -> IO () Source #

class Storable a where #

The member functions of this class facilitate writing values of primitive types to raw memory (which may have been allocated with the above mentioned routines) and reading values from blocks of raw memory. The class, furthermore, includes support for computing the storage requirements and alignment restrictions of storable types.

Memory addresses are represented as values of type Ptr a, for some a which is an instance of class Storable. The type argument to Ptr helps provide some valuable type safety in FFI code (you can't mix pointers of different types without an explicit cast), while helping the Haskell type system figure out which marshalling method is needed for a given pointer.

All marshalling between Haskell and a foreign language ultimately boils down to translating Haskell data structures into the binary representation of a corresponding data structure of the foreign language and vice versa. To code this marshalling in Haskell, it is necessary to manipulate primitive data types stored in unstructured memory blocks. The class Storable facilitates this manipulation on all types for which it is instantiated, which are the standard basic types of Haskell, the fixed size Int types (Int8, Int16, Int32, Int64), the fixed size Word types (Word8, Word16, Word32, Word64), StablePtr, all types from Foreign.C.Types, as well as Ptr.

Minimal complete definition

sizeOf, alignment, (peek | peekElemOff | peekByteOff), (poke | pokeElemOff | pokeByteOff)

Methods

sizeOf :: a -> Int #

Computes the storage requirements (in bytes) of the argument. The value of the argument is not used.

alignment :: a -> Int #

Computes the alignment constraint of the argument. An alignment constraint x is fulfilled by any address divisible by x. The value of the argument is not used.

peekElemOff :: Ptr a -> Int -> IO a #

Read a value from a memory area regarded as an array of values of the same kind. The first argument specifies the start address of the array and the second the index into the array (the first element of the array has index 0). The following equality holds,

peekElemOff addr idx = IOExts.fixIO $ \result ->
  peek (addr `plusPtr` (idx * sizeOf result))

Note that this is only a specification, not necessarily the concrete implementation of the function.

pokeElemOff :: Ptr a -> Int -> a -> IO () #

Write a value to a memory area regarded as an array of values of the same kind. The following equality holds:

pokeElemOff addr idx x = 
  poke (addr `plusPtr` (idx * sizeOf x)) x

peekByteOff :: Ptr b -> Int -> IO a #

Read a value from a memory location given by a base address and offset. The following equality holds:

peekByteOff addr off = peek (addr `plusPtr` off)

pokeByteOff :: Ptr b -> Int -> a -> IO () #

Write a value to a memory location given by a base address and offset. The following equality holds:

pokeByteOff addr off x = poke (addr `plusPtr` off) x

peek :: Ptr a -> IO a #

Read a value from the given memory location.

Note that the peek and poke functions might require properly aligned addresses to function correctly. This is architecture dependent; thus, portable code should ensure that when peeking or poking values of some type a, the alignment constraint for a, as given by the function alignment is fulfilled.

poke :: Ptr a -> a -> IO () #

Write the given value to the given memory location. Alignment restrictions might apply; see peek.

Instances

Instances details
Storable Bool

Since: base-2.1

Instance details

Defined in Foreign.Storable

Methods

sizeOf :: Bool -> Int #

alignment :: Bool -> Int #

peekElemOff :: Ptr Bool -> Int -> IO Bool #

pokeElemOff :: Ptr Bool -> Int -> Bool -> IO () #

peekByteOff :: Ptr b -> Int -> IO Bool #

pokeByteOff :: Ptr b -> Int -> Bool -> IO () #

peek :: Ptr Bool -> IO Bool #

poke :: Ptr Bool -> Bool -> IO () #

Storable Char

Since: base-2.1

Instance details

Defined in Foreign.Storable

Methods

sizeOf :: Char -> Int #

alignment :: Char -> Int #

peekElemOff :: Ptr Char -> Int -> IO Char #

pokeElemOff :: Ptr Char -> Int -> Char -> IO () #

peekByteOff :: Ptr b -> Int -> IO Char #

pokeByteOff :: Ptr b -> Int -> Char -> IO () #

peek :: Ptr Char -> IO Char #

poke :: Ptr Char -> Char -> IO () #

Storable Double

Since: base-2.1

Instance details

Defined in Foreign.Storable

Storable Float

Since: base-2.1

Instance details

Defined in Foreign.Storable

Methods

sizeOf :: Float -> Int #

alignment :: Float -> Int #

peekElemOff :: Ptr Float -> Int -> IO Float #

pokeElemOff :: Ptr Float -> Int -> Float -> IO () #

peekByteOff :: Ptr b -> Int -> IO Float #

pokeByteOff :: Ptr b -> Int -> Float -> IO () #

peek :: Ptr Float -> IO Float #

poke :: Ptr Float -> Float -> IO () #

Storable Int

Since: base-2.1

Instance details

Defined in Foreign.Storable

Methods

sizeOf :: Int -> Int #

alignment :: Int -> Int #

peekElemOff :: Ptr Int -> Int -> IO Int #

pokeElemOff :: Ptr Int -> Int -> Int -> IO () #

peekByteOff :: Ptr b -> Int -> IO Int #

pokeByteOff :: Ptr b -> Int -> Int -> IO () #

peek :: Ptr Int -> IO Int #

poke :: Ptr Int -> Int -> IO () #

Storable Int8

Since: base-2.1

Instance details

Defined in Foreign.Storable

Methods

sizeOf :: Int8 -> Int #

alignment :: Int8 -> Int #

peekElemOff :: Ptr Int8 -> Int -> IO Int8 #

pokeElemOff :: Ptr Int8 -> Int -> Int8 -> IO () #

peekByteOff :: Ptr b -> Int -> IO Int8 #

pokeByteOff :: Ptr b -> Int -> Int8 -> IO () #

peek :: Ptr Int8 -> IO Int8 #

poke :: Ptr Int8 -> Int8 -> IO () #

Storable Int16

Since: base-2.1

Instance details

Defined in Foreign.Storable

Methods

sizeOf :: Int16 -> Int #

alignment :: Int16 -> Int #

peekElemOff :: Ptr Int16 -> Int -> IO Int16 #

pokeElemOff :: Ptr Int16 -> Int -> Int16 -> IO () #

peekByteOff :: Ptr b -> Int -> IO Int16 #

pokeByteOff :: Ptr b -> Int -> Int16 -> IO () #

peek :: Ptr Int16 -> IO Int16 #

poke :: Ptr Int16 -> Int16 -> IO () #

Storable Int32

Since: base-2.1

Instance details

Defined in Foreign.Storable

Methods

sizeOf :: Int32 -> Int #

alignment :: Int32 -> Int #

peekElemOff :: Ptr Int32 -> Int -> IO Int32 #

pokeElemOff :: Ptr Int32 -> Int -> Int32 -> IO () #

peekByteOff :: Ptr b -> Int -> IO Int32 #

pokeByteOff :: Ptr b -> Int -> Int32 -> IO () #

peek :: Ptr Int32 -> IO Int32 #

poke :: Ptr Int32 -> Int32 -> IO () #

Storable Int64

Since: base-2.1

Instance details

Defined in Foreign.Storable

Methods

sizeOf :: Int64 -> Int #

alignment :: Int64 -> Int #

peekElemOff :: Ptr Int64 -> Int -> IO Int64 #

pokeElemOff :: Ptr Int64 -> Int -> Int64 -> IO () #

peekByteOff :: Ptr b -> Int -> IO Int64 #

pokeByteOff :: Ptr b -> Int -> Int64 -> IO () #

peek :: Ptr Int64 -> IO Int64 #

poke :: Ptr Int64 -> Int64 -> IO () #

Storable Word

Since: base-2.1

Instance details

Defined in Foreign.Storable

Methods

sizeOf :: Word -> Int #

alignment :: Word -> Int #

peekElemOff :: Ptr Word -> Int -> IO Word #

pokeElemOff :: Ptr Word -> Int -> Word -> IO () #

peekByteOff :: Ptr b -> Int -> IO Word #

pokeByteOff :: Ptr b -> Int -> Word -> IO () #

peek :: Ptr Word -> IO Word #

poke :: Ptr Word -> Word -> IO () #

Storable Word8

Since: base-2.1

Instance details

Defined in Foreign.Storable

Methods

sizeOf :: Word8 -> Int #

alignment :: Word8 -> Int #

peekElemOff :: Ptr Word8 -> Int -> IO Word8 #

pokeElemOff :: Ptr Word8 -> Int -> Word8 -> IO () #

peekByteOff :: Ptr b -> Int -> IO Word8 #

pokeByteOff :: Ptr b -> Int -> Word8 -> IO () #

peek :: Ptr Word8 -> IO Word8 #

poke :: Ptr Word8 -> Word8 -> IO () #

Storable Word16

Since: base-2.1

Instance details

Defined in Foreign.Storable

Storable Word32

Since: base-2.1

Instance details

Defined in Foreign.Storable

Storable Word64

Since: base-2.1

Instance details

Defined in Foreign.Storable

Storable ()

Since: base-4.9.0.0

Instance details

Defined in Foreign.Storable

Methods

sizeOf :: () -> Int #

alignment :: () -> Int #

peekElemOff :: Ptr () -> Int -> IO () #

pokeElemOff :: Ptr () -> Int -> () -> IO () #

peekByteOff :: Ptr b -> Int -> IO () #

pokeByteOff :: Ptr b -> Int -> () -> IO () #

peek :: Ptr () -> IO () #

poke :: Ptr () -> () -> IO () #

GStorable a => Storable a Source # 
Instance details

Defined in Foreign.Storable.Generic.Internal

Methods

sizeOf :: a -> Int #

alignment :: a -> Int #

peekElemOff :: Ptr a -> Int -> IO a #

pokeElemOff :: Ptr a -> Int -> a -> IO () #

peekByteOff :: Ptr b -> Int -> IO a #

pokeByteOff :: Ptr b -> Int -> a -> IO () #

peek :: Ptr a -> IO a #

poke :: Ptr a -> a -> IO () #

Storable CChar 
Instance details

Defined in Foreign.C.Types

Methods

sizeOf :: CChar -> Int #

alignment :: CChar -> Int #

peekElemOff :: Ptr CChar -> Int -> IO CChar #

pokeElemOff :: Ptr CChar -> Int -> CChar -> IO () #

peekByteOff :: Ptr b -> Int -> IO CChar #

pokeByteOff :: Ptr b -> Int -> CChar -> IO () #

peek :: Ptr CChar -> IO CChar #

poke :: Ptr CChar -> CChar -> IO () #

Storable CSChar 
Instance details

Defined in Foreign.C.Types

Storable CUChar 
Instance details

Defined in Foreign.C.Types

Storable CShort 
Instance details

Defined in Foreign.C.Types

Storable CUShort 
Instance details

Defined in Foreign.C.Types

Storable CInt 
Instance details

Defined in Foreign.C.Types

Methods

sizeOf :: CInt -> Int #

alignment :: CInt -> Int #

peekElemOff :: Ptr CInt -> Int -> IO CInt #

pokeElemOff :: Ptr CInt -> Int -> CInt -> IO () #

peekByteOff :: Ptr b -> Int -> IO CInt #

pokeByteOff :: Ptr b -> Int -> CInt -> IO () #

peek :: Ptr CInt -> IO CInt #

poke :: Ptr CInt -> CInt -> IO () #

Storable CUInt 
Instance details

Defined in Foreign.C.Types

Methods

sizeOf :: CUInt -> Int #

alignment :: CUInt -> Int #

peekElemOff :: Ptr CUInt -> Int -> IO CUInt #

pokeElemOff :: Ptr CUInt -> Int -> CUInt -> IO () #

peekByteOff :: Ptr b -> Int -> IO CUInt #

pokeByteOff :: Ptr b -> Int -> CUInt -> IO () #

peek :: Ptr CUInt -> IO CUInt #

poke :: Ptr CUInt -> CUInt -> IO () #

Storable CLong 
Instance details

Defined in Foreign.C.Types

Methods

sizeOf :: CLong -> Int #

alignment :: CLong -> Int #

peekElemOff :: Ptr CLong -> Int -> IO CLong #

pokeElemOff :: Ptr CLong -> Int -> CLong -> IO () #

peekByteOff :: Ptr b -> Int -> IO CLong #

pokeByteOff :: Ptr b -> Int -> CLong -> IO () #

peek :: Ptr CLong -> IO CLong #

poke :: Ptr CLong -> CLong -> IO () #

Storable CULong 
Instance details

Defined in Foreign.C.Types

Storable CLLong 
Instance details

Defined in Foreign.C.Types

Storable CULLong 
Instance details

Defined in Foreign.C.Types

Storable CBool 
Instance details

Defined in Foreign.C.Types

Methods

sizeOf :: CBool -> Int #

alignment :: CBool -> Int #

peekElemOff :: Ptr CBool -> Int -> IO CBool #

pokeElemOff :: Ptr CBool -> Int -> CBool -> IO () #

peekByteOff :: Ptr b -> Int -> IO CBool #

pokeByteOff :: Ptr b -> Int -> CBool -> IO () #

peek :: Ptr CBool -> IO CBool #

poke :: Ptr CBool -> CBool -> IO () #

Storable CFloat 
Instance details

Defined in Foreign.C.Types

Storable CDouble 
Instance details

Defined in Foreign.C.Types

Storable CPtrdiff 
Instance details

Defined in Foreign.C.Types

Storable CSize 
Instance details

Defined in Foreign.C.Types

Methods

sizeOf :: CSize -> Int #

alignment :: CSize -> Int #

peekElemOff :: Ptr CSize -> Int -> IO CSize #

pokeElemOff :: Ptr CSize -> Int -> CSize -> IO () #

peekByteOff :: Ptr b -> Int -> IO CSize #

pokeByteOff :: Ptr b -> Int -> CSize -> IO () #

peek :: Ptr CSize -> IO CSize #

poke :: Ptr CSize -> CSize -> IO () #

Storable CWchar 
Instance details

Defined in Foreign.C.Types

Storable CSigAtomic 
Instance details

Defined in Foreign.C.Types

Storable CClock 
Instance details

Defined in Foreign.C.Types

Storable CTime 
Instance details

Defined in Foreign.C.Types

Methods

sizeOf :: CTime -> Int #

alignment :: CTime -> Int #

peekElemOff :: Ptr CTime -> Int -> IO CTime #

pokeElemOff :: Ptr CTime -> Int -> CTime -> IO () #

peekByteOff :: Ptr b -> Int -> IO CTime #

pokeByteOff :: Ptr b -> Int -> CTime -> IO () #

peek :: Ptr CTime -> IO CTime #

poke :: Ptr CTime -> CTime -> IO () #

Storable CUSeconds 
Instance details

Defined in Foreign.C.Types

Storable CSUSeconds 
Instance details

Defined in Foreign.C.Types

Storable CIntPtr 
Instance details

Defined in Foreign.C.Types

Storable CUIntPtr 
Instance details

Defined in Foreign.C.Types

Storable CIntMax 
Instance details

Defined in Foreign.C.Types

Storable CUIntMax 
Instance details

Defined in Foreign.C.Types

Storable WordPtr 
Instance details

Defined in Foreign.Ptr

Storable IntPtr 
Instance details

Defined in Foreign.Ptr

Storable Fingerprint

Since: base-4.4.0.0

Instance details

Defined in Foreign.Storable

(Storable a, Integral a) => Storable (Ratio a)

Since: base-4.8.0.0

Instance details

Defined in Foreign.Storable

Methods

sizeOf :: Ratio a -> Int #

alignment :: Ratio a -> Int #

peekElemOff :: Ptr (Ratio a) -> Int -> IO (Ratio a) #

pokeElemOff :: Ptr (Ratio a) -> Int -> Ratio a -> IO () #

peekByteOff :: Ptr b -> Int -> IO (Ratio a) #

pokeByteOff :: Ptr b -> Int -> Ratio a -> IO () #

peek :: Ptr (Ratio a) -> IO (Ratio a) #

poke :: Ptr (Ratio a) -> Ratio a -> IO () #

Storable (StablePtr a)

Since: base-2.1

Instance details

Defined in Foreign.Storable

Methods

sizeOf :: StablePtr a -> Int #

alignment :: StablePtr a -> Int #

peekElemOff :: Ptr (StablePtr a) -> Int -> IO (StablePtr a) #

pokeElemOff :: Ptr (StablePtr a) -> Int -> StablePtr a -> IO () #

peekByteOff :: Ptr b -> Int -> IO (StablePtr a) #

pokeByteOff :: Ptr b -> Int -> StablePtr a -> IO () #

peek :: Ptr (StablePtr a) -> IO (StablePtr a) #

poke :: Ptr (StablePtr a) -> StablePtr a -> IO () #

Storable (Ptr a)

Since: base-2.1

Instance details

Defined in Foreign.Storable

Methods

sizeOf :: Ptr a -> Int #

alignment :: Ptr a -> Int #

peekElemOff :: Ptr (Ptr a) -> Int -> IO (Ptr a) #

pokeElemOff :: Ptr (Ptr a) -> Int -> Ptr a -> IO () #

peekByteOff :: Ptr b -> Int -> IO (Ptr a) #

pokeByteOff :: Ptr b -> Int -> Ptr a -> IO () #

peek :: Ptr (Ptr a) -> IO (Ptr a) #

poke :: Ptr (Ptr a) -> Ptr a -> IO () #

Storable (FunPtr a)

Since: base-2.1

Instance details

Defined in Foreign.Storable

Methods

sizeOf :: FunPtr a -> Int #

alignment :: FunPtr a -> Int #

peekElemOff :: Ptr (FunPtr a) -> Int -> IO (FunPtr a) #

pokeElemOff :: Ptr (FunPtr a) -> Int -> FunPtr a -> IO () #

peekByteOff :: Ptr b -> Int -> IO (FunPtr a) #

pokeByteOff :: Ptr b -> Int -> FunPtr a -> IO () #

peek :: Ptr (FunPtr a) -> IO (FunPtr a) #

poke :: Ptr (FunPtr a) -> FunPtr a -> IO () #

Storable a => Storable (Down a)

Since: base-4.14.0.0

Instance details

Defined in Data.Ord

Methods

sizeOf :: Down a -> Int #

alignment :: Down a -> Int #

peekElemOff :: Ptr (Down a) -> Int -> IO (Down a) #

pokeElemOff :: Ptr (Down a) -> Int -> Down a -> IO () #

peekByteOff :: Ptr b -> Int -> IO (Down a) #

pokeByteOff :: Ptr b -> Int -> Down a -> IO () #

peek :: Ptr (Down a) -> IO (Down a) #

poke :: Ptr (Down a) -> Down a -> IO () #

class GStorableSum' f where Source #

Work on the sum type.

Methods

seeFirstByte' :: f p -> Int -> Word8 Source #

gsizeOfSum' :: f p -> Int Source #

The size of the biggest subtree

alignOfSum' :: f p -> Int Source #

Alignment of the biggest subtree

gpeekByteOffSum' :: Int -> Ptr b -> Int -> IO (f p) Source #

Peek the type based on the tag.

gpokeByteOffSum' :: Ptr b -> Int -> f p -> IO () Source #

Instances

Instances details
GStorableSum' (V1 :: Type -> Type) Source # 
Instance details

Defined in Foreign.Storable.Generic.Internal

Methods

seeFirstByte' :: V1 p -> Int -> Word8 Source #

gsizeOfSum' :: V1 p -> Int Source #

alignOfSum' :: V1 p -> Int Source #

gpeekByteOffSum' :: Int -> Ptr b -> Int -> IO (V1 p) Source #

gpokeByteOffSum' :: Ptr b -> Int -> V1 p -> IO () Source #

GStorableSum' (U1 :: Type -> Type) Source # 
Instance details

Defined in Foreign.Storable.Generic.Internal

Methods

seeFirstByte' :: U1 p -> Int -> Word8 Source #

gsizeOfSum' :: U1 p -> Int Source #

alignOfSum' :: U1 p -> Int Source #

gpeekByteOffSum' :: Int -> Ptr b -> Int -> IO (U1 p) Source #

gpokeByteOffSum' :: Ptr b -> Int -> U1 p -> IO () Source #

GStorableSum' (K1 i a :: Type -> Type) Source # 
Instance details

Defined in Foreign.Storable.Generic.Internal

Methods

seeFirstByte' :: K1 i a p -> Int -> Word8 Source #

gsizeOfSum' :: K1 i a p -> Int Source #

alignOfSum' :: K1 i a p -> Int Source #

gpeekByteOffSum' :: Int -> Ptr b -> Int -> IO (K1 i a p) Source #

gpokeByteOffSum' :: Ptr b -> Int -> K1 i a p -> IO () Source #

(KnownNat (SumArity g), KnownNat (SumArity f), GStorableSum' f, GStorableSum' g) => GStorableSum' (f :+: g) Source # 
Instance details

Defined in Foreign.Storable.Generic.Internal

Methods

seeFirstByte' :: (f :+: g) p -> Int -> Word8 Source #

gsizeOfSum' :: (f :+: g) p -> Int Source #

alignOfSum' :: (f :+: g) p -> Int Source #

gpeekByteOffSum' :: Int -> Ptr b -> Int -> IO ((f :+: g) p) Source #

gpokeByteOffSum' :: Ptr b -> Int -> (f :+: g) p -> IO () Source #

GStorableSum' (f :*: g) Source # 
Instance details

Defined in Foreign.Storable.Generic.Internal

Methods

seeFirstByte' :: (f :*: g) p -> Int -> Word8 Source #

gsizeOfSum' :: (f :*: g) p -> Int Source #

alignOfSum' :: (f :*: g) p -> Int Source #

gpeekByteOffSum' :: Int -> Ptr b -> Int -> IO ((f :*: g) p) Source #

gpokeByteOffSum' :: Ptr b -> Int -> (f :*: g) p -> IO () Source #

GStorableSum' f => GStorableSum' (M1 D t f) Source # 
Instance details

Defined in Foreign.Storable.Generic.Internal

Methods

seeFirstByte' :: M1 D t f p -> Int -> Word8 Source #

gsizeOfSum' :: M1 D t f p -> Int Source #

alignOfSum' :: M1 D t f p -> Int Source #

gpeekByteOffSum' :: Int -> Ptr b -> Int -> IO (M1 D t f p) Source #

gpokeByteOffSum' :: Ptr b -> Int -> M1 D t f p -> IO () Source #

(KnownNat (NoFields f), GStorable' f, GStorableSum' f) => GStorableSum' (M1 C t f) Source # 
Instance details

Defined in Foreign.Storable.Generic.Internal

Methods

seeFirstByte' :: M1 C t f p -> Int -> Word8 Source #

gsizeOfSum' :: M1 C t f p -> Int Source #

alignOfSum' :: M1 C t f p -> Int Source #

gpeekByteOffSum' :: Int -> Ptr b -> Int -> IO (M1 C t f p) Source #

gpokeByteOffSum' :: Ptr b -> Int -> M1 C t f p -> IO () Source #

GStorableSum' f => GStorableSum' (M1 S t f) Source # 
Instance details

Defined in Foreign.Storable.Generic.Internal

Methods

seeFirstByte' :: M1 S t f p -> Int -> Word8 Source #

gsizeOfSum' :: M1 S t f p -> Int Source #

alignOfSum' :: M1 S t f p -> Int Source #

gpeekByteOffSum' :: Int -> Ptr b -> Int -> IO (M1 S t f p) Source #

gpokeByteOffSum' :: Ptr b -> Int -> M1 S t f p -> IO () Source #

class GStorableChoice' (choice :: Bool) a where Source #

Choose a GStorable implementation - whether a sum type (with tag) or raw product type (without the tag).

Methods

chSizeOf :: proxy choice -> a -> Int Source #

chAlignment :: proxy choice -> a -> Int Source #

chPeekByteOff :: proxy choice -> Ptr b -> Int -> IO a Source #

chPokeByteOff :: proxy choice -> Ptr b -> Int -> a -> IO () Source #

Instances

Instances details
(ConstraintsAll a, IsSumType (Rep a) ~ 'False) => GStorableChoice' 'False a Source #

Implementation for the non-sum types.

Instance details

Defined in Foreign.Storable.Generic.Internal

Methods

chSizeOf :: proxy 'False -> a -> Int Source #

chAlignment :: proxy 'False -> a -> Int Source #

chPeekByteOff :: proxy 'False -> Ptr b -> Int -> IO a Source #

chPokeByteOff :: proxy 'False -> Ptr b -> Int -> a -> IO () Source #

(Generic a, KnownNat (SumArity (Rep a)), GStorableSum' (Rep a), IsSumType (Rep a) ~ 'True) => GStorableChoice' 'True a Source #

Implementation for the sum types.

Instance details

Defined in Foreign.Storable.Generic.Internal

Methods

chSizeOf :: proxy 'True -> a -> Int Source #

chAlignment :: proxy 'True -> a -> Int Source #

chPeekByteOff :: proxy 'True -> Ptr b -> Int -> IO a Source #

chPokeByteOff :: proxy 'True -> Ptr b -> Int -> a -> IO () Source #

internalTagValue :: (KnownNat (SumArity (Rep a)), GStorableSum' (Rep a), Generic a) => a -> Word8 Source #

Get the tag value from the generic representation.

internalSizeOf Source #

Arguments

:: forall f p. GStorable' f 
=> f p

Generic representation

-> Int

Resulting size

Calculates the size of generic data-type.

internalAlignment Source #

Arguments

:: forall f p. GStorable' f 
=> f p

Generic representation

-> Alignment

Resulting alignment

Calculates the alignment of generic data-type.

internalPeekByteOff Source #

Arguments

:: forall f p b. (KnownNat (NoFields f), 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

:: forall f p b. (KnownNat (NoFields f), 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

Orphan instances

GStorable a => Storable a Source # 
Instance details

Methods

sizeOf :: a -> Int #

alignment :: a -> Int #

peekElemOff :: Ptr a -> Int -> IO a #

pokeElemOff :: Ptr a -> Int -> a -> IO () #

peekByteOff :: Ptr b -> Int -> IO a #

pokeByteOff :: Ptr b -> Int -> a -> IO () #

peek :: Ptr a -> IO a #

poke :: Ptr a -> a -> IO () #