Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data EnumOf enum where
- type BitRecordOfEnum (e :: Extends (EnumOf enum)) = (RenderEnumOf (From e) :: BitRecord)
- type family RenderEnumOf (e :: EnumOf enum) :: BitRecord where ...
- data EnumField (enum :: Type) (size :: Nat)
- type BitRecordFieldOfEnumField (x :: Extends (EnumField e s)) = MkField (MkFieldCustom :: BitField (EnumValue e) e s)
- data FixedEnum (enum :: Type) (size :: Nat) :: Extends (EnumField enum size)
- data ExtEnum (enum :: Type) (size :: Nat) (extInd :: enum) (extField :: Extends (BitRecordField (t :: BitField rt0 (st0 :: k0) len0))) :: Extends (EnumField enum size)
- data SetEnum (l :: Symbol) (ef :: Extends (EnumField enum size)) (v :: enum) :: Extends (EnumOf enum)
- data EnumParam (label :: Symbol) (ef :: Extends (EnumField (enum :: Type) (size :: Nat))) :: Extends (EnumOf enum)
- data SetEnumAlt (l :: Symbol) (ef :: Extends (EnumField (enum :: Type) (size :: Nat))) (v :: k) :: Extends (EnumOf enum)
- data EnumParamAlt (label :: Symbol) (ef :: Extends (EnumField (enum :: Type) (size :: Nat))) :: Extends (EnumOf enum)
- type family FromEnum enum (entry :: enum) :: Nat
- data EnumValue e where
- MkEnumValue :: KnownNat (FromEnum e v) => Proxy (v :: e) -> EnumValue e
- enumValueProxy :: KnownNat (FromEnum e v) => Proxy (v :: e) -> EnumValue e
- fromEnumValue :: EnumValue e -> Word64
BitRecordFields containing enum-like types
data EnumOf enum where Source #
Wrapper around a type that can be represented as a short number, indexing the clauses of the (sum) type.
MkEnumOf :: Extends (EnumField enum size) -> Extends (FieldValue label enum) -> BitRecord -> EnumOf enum |
Instances
type From (EnumParam label ei :: EnumOf enum -> Type) Source # | |
Defined in Data.Type.BitRecords.Enum type From (EnumParam label ei :: EnumOf enum -> Type) = MkEnumOf ei (RuntimeFieldValue label :: FieldValue label enum -> Type) EmptyBitRecord | |
type From (EnumParamAlt label (FixedEnum enum size) :: EnumOf enum -> Type) Source # | |
type From (EnumParamAlt label (ExtEnum enum size extInd extField) :: EnumOf enum -> Type) Source # | |
Defined in Data.Type.BitRecords.Enum type From (EnumParamAlt label (ExtEnum enum size extInd extField) :: EnumOf enum -> Type) = MkEnumOf (ExtEnum enum size extInd extField) (StaticFieldValue label extInd) (BitRecordMember (extField :~ (RuntimeFieldValue label :: FieldValue label st -> Type))) | |
type From (SetEnum l ei value :: EnumOf enum -> Type) Source # | |
Defined in Data.Type.BitRecords.Enum type From (SetEnum l ei value :: EnumOf enum -> Type) = MkEnumOf ei (StaticFieldValue l value) EmptyBitRecord | |
type From (SetEnumAlt l (FixedEnum enum size) value :: EnumOf enum -> Type) Source # | |
type From (SetEnumAlt l (ExtEnum enum size extInd extField) value :: EnumOf enum -> Type) Source # | |
Defined in Data.Type.BitRecords.Enum type From (SetEnumAlt l (ExtEnum enum size extInd extField) value :: EnumOf enum -> Type) = MkEnumOf (ExtEnum enum size extInd extField) (StaticFieldValue l extInd) (BitRecordMember (extField := value)) |
type BitRecordOfEnum (e :: Extends (EnumOf enum)) = (RenderEnumOf (From e) :: BitRecord) Source #
type family RenderEnumOf (e :: EnumOf enum) :: BitRecord where ... Source #
RenderEnumOf (MkEnumOf mainField mainFieldVal extra) = (BitRecordFieldOfEnumField mainField :~ mainFieldVal) .+: extra |
data EnumField (enum :: Type) (size :: Nat) Source #
Physical representation of an EnumOf
, this is an abstract type
type BitRecordFieldOfEnumField (x :: Extends (EnumField e s)) = MkField (MkFieldCustom :: BitField (EnumValue e) e s) Source #
data FixedEnum (enum :: Type) (size :: Nat) :: Extends (EnumField enum size) Source #
A fixed size EnumField
data ExtEnum (enum :: Type) (size :: Nat) (extInd :: enum) (extField :: Extends (BitRecordField (t :: BitField rt0 (st0 :: k0) len0))) :: Extends (EnumField enum size) Source #
An enum that can be extended with an additional BitRecordField
, following
the regular enum field; the extension is optional, i.e. only if the
regular field contains a special value (e.g. 0xff).
Instances
type From (EnumParamAlt label (ExtEnum enum size extInd extField) :: EnumOf enum -> Type) Source # | |
Defined in Data.Type.BitRecords.Enum type From (EnumParamAlt label (ExtEnum enum size extInd extField) :: EnumOf enum -> Type) = MkEnumOf (ExtEnum enum size extInd extField) (StaticFieldValue label extInd) (BitRecordMember (extField :~ (RuntimeFieldValue label :: FieldValue label st -> Type))) | |
type From (SetEnumAlt l (ExtEnum enum size extInd extField) value :: EnumOf enum -> Type) Source # | |
Defined in Data.Type.BitRecords.Enum type From (SetEnumAlt l (ExtEnum enum size extInd extField) value :: EnumOf enum -> Type) = MkEnumOf (ExtEnum enum size extInd extField) (StaticFieldValue l extInd) (BitRecordMember (extField := value)) |
data SetEnum (l :: Symbol) (ef :: Extends (EnumField enum size)) (v :: enum) :: Extends (EnumOf enum) Source #
Create an EnumOf
that sets an enum to a static value.
Instances
type From (SetEnum l ei value :: EnumOf enum -> Type) Source # | |
Defined in Data.Type.BitRecords.Enum type From (SetEnum l ei value :: EnumOf enum -> Type) = MkEnumOf ei (StaticFieldValue l value) EmptyBitRecord |
data EnumParam (label :: Symbol) (ef :: Extends (EnumField (enum :: Type) (size :: Nat))) :: Extends (EnumOf enum) Source #
Create an EnumOf
that sets the enum to a runtime value.
Instances
type From (EnumParam label ei :: EnumOf enum -> Type) Source # | |
Defined in Data.Type.BitRecords.Enum type From (EnumParam label ei :: EnumOf enum -> Type) = MkEnumOf ei (RuntimeFieldValue label :: FieldValue label enum -> Type) EmptyBitRecord |
data SetEnumAlt (l :: Symbol) (ef :: Extends (EnumField (enum :: Type) (size :: Nat))) (v :: k) :: Extends (EnumOf enum) Source #
Create an EnumOf
that sets an extended enum to an extended static value.
Instances
type From (SetEnumAlt l (FixedEnum enum size) value :: EnumOf enum -> Type) Source # | |
type From (SetEnumAlt l (ExtEnum enum size extInd extField) value :: EnumOf enum -> Type) Source # | |
Defined in Data.Type.BitRecords.Enum type From (SetEnumAlt l (ExtEnum enum size extInd extField) value :: EnumOf enum -> Type) = MkEnumOf (ExtEnum enum size extInd extField) (StaticFieldValue l extInd) (BitRecordMember (extField := value)) |
data EnumParamAlt (label :: Symbol) (ef :: Extends (EnumField (enum :: Type) (size :: Nat))) :: Extends (EnumOf enum) Source #
Create an EnumOf
that sets the extended enum to a runtime value.
Instances
type From (EnumParamAlt label (FixedEnum enum size) :: EnumOf enum -> Type) Source # | |
type From (EnumParamAlt label (ExtEnum enum size extInd extField) :: EnumOf enum -> Type) Source # | |
Defined in Data.Type.BitRecords.Enum type From (EnumParamAlt label (ExtEnum enum size extInd extField) :: EnumOf enum -> Type) = MkEnumOf (ExtEnum enum size extInd extField) (StaticFieldValue label extInd) (BitRecordMember (extField :~ (RuntimeFieldValue label :: FieldValue label st -> Type))) |
Composing BitRecords with enum fields
type family FromEnum enum (entry :: enum) :: Nat Source #
Return the numeric index of an entry in a table. This emulates fromEnum
a bit.
Instances
data EnumValue e where Source #
An enum value supplied at runtime.
MkEnumValue :: KnownNat (FromEnum e v) => Proxy (v :: e) -> EnumValue e |
Instances
fromEnumValue :: EnumValue e -> Word64 Source #