binrep-0.5.0: Encode precise binary representations directly in types
Safe HaskellSafe-Inferred
LanguageGHC2021

Binrep.Type.NullPadded

Synopsis

Documentation

data NullPad (n :: Natural) Source #

Instances

Instances details
(BLen a, KnownNat n) => Predicate (NullPad n :: Type) a Source # 
Instance details

Defined in Binrep.Type.NullPadded

(BLen a, Get a, KnownNat n) => Get (NullPadded n a) Source # 
Instance details

Defined in Binrep.Type.NullPadded

Methods

get :: Getter (NullPadded n a) Source #

(BLen a, Put a, KnownNat n) => Put (NullPadded n a) Source # 
Instance details

Defined in Binrep.Type.NullPadded

Methods

put :: NullPadded n a -> Poke Source #

type NullPadded n a = Refined (NullPad n) a Source #

A type which is to be null-padded to a given total length.

Given some a :: NullPadded n a, it is guaranteed that

blen a <= natValInt @n

thus

natValInt @n - blen a >= 0

That is, the serialized stored data will not be longer than the total length.

The binrep instances are careful not to construct bytestrings unnecessarily.