Safe Haskell | None |
---|---|
Language | Haskell2010 |
Record (similar to C struct)
Synopsis
- data Record (fields :: [*])
- data Field (name :: Symbol) typ
- type family RecordSize (fs :: [*]) (sz :: Nat) where ...
- type family Alignment a :: Nat
- type family Modulo (a :: Nat) (b :: Nat) :: Nat where ...
- data Path (fs :: [Symbol])
- recordSize :: forall fs. KnownNat (FullRecordSize fs) => Record fs -> Word
- recordAlignment :: forall fs. KnownNat (RecordAlignment fs 1) => Record fs -> Word
- recordField :: forall (name :: Symbol) a fs. (KnownNat (FieldOffset name fs 0), a ~ FieldType name fs, StaticStorable a) => Record fs -> a
- recordFieldOffset :: forall (name :: Symbol) 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
data Record (fields :: [*]) Source #
Record
Instances
(HFoldr' Extract (Record fs, HList ([] :: [Type])) fs (Record fs, HList fs), Show (HList fs)) => Show (Record fs) Source # | |
(s ~ FullRecordSize fs, KnownNat s) => StaticStorable (Record fs) Source # | |
type SizeOf (Record fs) Source # | |
Defined in Haskus.Format.Binary.Record | |
type Alignment (Record fs) Source # | |
Defined in Haskus.Format.Binary.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) |
type family Alignment a :: Nat Source #
Alignment requirement (in bytes)
Instances
recordAlignment :: forall fs. KnownNat (RecordAlignment fs 1) => Record fs -> Word Source #
Get record alignment
recordField :: forall (name :: Symbol) a fs. (KnownNat (FieldOffset name fs 0), a ~ FieldType name fs, StaticStorable a) => Record fs -> a Source #
Get a field
recordFieldOffset :: forall (name :: Symbol) 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