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
- 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.Binary.Record | |
type Alignment (Record fs) Source # | |
Defined in Haskus.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
type Alignment Int8 Source # | |
Defined in Haskus.Binary.Storable | |
type Alignment Int16 Source # | |
Defined in Haskus.Binary.Storable | |
type Alignment Int32 Source # | |
Defined in Haskus.Binary.Storable | |
type Alignment Int64 Source # | |
Defined in Haskus.Binary.Storable | |
type Alignment Word8 Source # | |
Defined in Haskus.Binary.Storable | |
type Alignment Word16 Source # | |
Defined in Haskus.Binary.Storable | |
type Alignment Word32 Source # | |
Defined in Haskus.Binary.Storable | |
type Alignment Word64 Source # | |
Defined in Haskus.Binary.Storable | |
type Alignment (Union fs) Source # | |
Defined in Haskus.Binary.Union | |
type Alignment (Record fs) Source # | |
Defined in Haskus.Binary.Record | |
type Alignment (AsLittleEndian a) Source # | |
Defined in Haskus.Binary.Endianness | |
type Alignment (AsBigEndian a) Source # | |
Defined in Haskus.Binary.Endianness | |
type Alignment (EnumField b a) Source # | |
Defined in Haskus.Binary.Enum | |
type Alignment (Vector n a) Source # | |
Defined in Haskus.Binary.Vector |
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