haskus-system-0.6.0.0: Haskus system programming framework

Safe HaskellNone
LanguageHaskell2010

Haskus.Format.Binary.Record

Description

Record (similar to C struct)

Synopsis

Documentation

data Record fields Source #

Record

Instances

(HFoldr' Extract (Record fs, HList ([] *)) fs (Record fs, HList fs), Show (HList fs)) => Show (Record fs) Source # 

Methods

showsPrec :: Int -> Record fs -> ShowS #

show :: Record fs -> String #

showList :: [Record fs] -> ShowS #

((~) Nat s (FullRecordSize fs), KnownNat s) => StaticStorable (Record fs) Source # 

Associated Types

type SizeOf (Record fs) :: Nat Source #

type Alignment (Record fs) :: Nat Source #

Methods

staticPeekIO :: Ptr (Record fs) -> IO (Record fs) Source #

staticPokeIO :: Ptr (Record fs) -> Record fs -> IO () Source #

type SizeOf (Record fs) Source # 
type SizeOf (Record fs)
type Alignment (Record fs) Source # 
type Alignment (Record fs)

data Field name typ Source #

Field

type family RecordSize (fs :: [*]) (sz :: Nat) where ... Source #

Get record size without the ending padding bytes

Equations

RecordSize '[] sz = sz 
RecordSize (Field name typ ': fs) sz = RecordSize fs ((sz + Padding sz typ) + SizeOf typ) 

type family Modulo (a :: Nat) (b :: Nat) where ... Source #

Modulo

Equations

Modulo a b = Modulo' (a <=? b) a b 

data Path fs Source #

recordSize :: forall fs. KnownNat (FullRecordSize fs) => Record fs -> Word Source #

Get record size

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

recordFieldPathOffset :: forall path fs o. (o ~ FieldPathOffset fs path 0, KnownNat o) => Path path -> Record fs -> Int Source #

Get a field offset from its path

recordToList :: forall fs. HFoldr' Extract (Record fs, HList '[]) fs (Record fs, HList fs) => Record fs -> HList fs Source #

Convert a record into a HList