Safe Haskell | None |
---|---|
Language | Haskell2010 |
Record (similar to C struct)
- data Record fields
- data Field name typ
- type family RecordSize (fs :: [*]) (sz :: Nat) where ...
- type family Modulo (a :: Nat) (b :: Nat) :: Nat where ...
- data Path fs
- recordSize :: forall fs. KnownNat (FullRecordSize fs) => Record fs -> Word
- recordAlignment :: forall fs. KnownNat (RecordAlignment fs 1) => Record fs -> Word
- recordField :: forall name a fs. (KnownNat (FieldOffset name fs 0), a ~ FieldType name fs, StaticStorable a) => Record fs -> a
- recordFieldOffset :: forall name fs. KnownNat (FieldOffset name fs 0) => Record fs -> Int
- recordFieldPath :: forall path a fs o. (o ~ FieldPathOffset fs path 0, a ~ FieldPathType fs path, KnownNat o, StaticStorable a) => Path path -> Record fs -> a
- recordFieldPathOffset :: forall path fs o. (o ~ FieldPathOffset fs path 0, KnownNat o) => Path path -> Record fs -> Int
- recordToList :: forall fs. HFoldr' Extract (Record fs, HList '[]) fs (Record fs, HList fs) => Record fs -> HList fs
Documentation
Record
type family RecordSize (fs :: [*]) (sz :: Nat) where ... Source #
Get record size without the ending padding bytes
RecordSize '[] sz = sz | |
RecordSize (Field name typ ': fs) sz = RecordSize fs ((sz + Padding sz typ) + SizeOf typ) |
recordAlignment :: forall fs. KnownNat (RecordAlignment fs 1) => Record fs -> Word Source #
Get record alignment
recordField :: forall name a fs. (KnownNat (FieldOffset name fs 0), a ~ FieldType name fs, StaticStorable a) => Record fs -> a Source #
Get a field
recordFieldOffset :: forall name fs. KnownNat (FieldOffset name fs 0) => Record fs -> Int Source #
Get a field offset
recordFieldPath :: forall path a fs o. (o ~ FieldPathOffset fs path 0, a ~ FieldPathType fs path, KnownNat o, StaticStorable a) => Path path -> Record fs -> a Source #
Get a field from its path