Copyright | (c) Fumiaki Kinoshita 2018 |
---|---|

License | BSD3 |

Maintainer | Fumiaki Kinoshita <fumiexcel@gmail.com> |

Safe Haskell | None |

Language | Haskell2010 |

Bit-packed records

- newtype BitProd r (h :: k -> *) (xs :: [k]) = BitProd {
- unBitProd :: r

- class (Bits r, KnownNat (BitWidth a)) => FromBits r a where
- type family TotalBits h xs where ...
- type BitFields r h xs = (FromBits r r, TotalBits h xs <= BitWidth r, Forall (Instance1 (FromBits r) h) xs)
- blookup :: forall x r h xs. (BitFields r h xs, FromBits r (h x)) => Membership xs x -> BitProd r h xs -> h x
- bupdate :: forall x r h xs. (BitFields r h xs, FromBits r (h x)) => Membership xs x -> BitProd r h xs -> h x -> BitProd r h xs
- toBitProd :: forall r h xs. BitFields r h xs => (h :* xs) -> BitProd r h xs
- fromBitProd :: forall r h xs. BitFields r h xs => BitProd r h xs -> h :* xs
- type BitRecordOf r h = BitProd r (Field h)
- type BitRecord r = BitRecordOf r Identity

# Documentation

newtype BitProd r (h :: k -> *) (xs :: [k]) Source #

Bit-vector product. It has similar interface as `(:*)`

but fields are packed into `r`

.

(Corepresentable p, Comonad (Corep p), Functor f) => Extensible k f p (BitProd k r) Source # | |

(Bits r, KnownNat (TotalBits k h xs)) => FromBits r (BitProd k r h xs) Source # | |

Bounded r => Bounded (BitProd k r h xs) Source # | |

Enum r => Enum (BitProd k r h xs) Source # | |

Eq r => Eq (BitProd k r h xs) Source # | |

Ord r => Ord (BitProd k r h xs) Source # | |

(Forall k (Instance1 * k Show h) xs, BitFields k r h xs) => Show (BitProd k r h xs) Source # | |

Ix r => Ix (BitProd k r h xs) Source # | |

Generic (BitProd k r h xs) Source # | |

Hashable r => Hashable (BitProd k r h xs) Source # | |

Storable r => Storable (BitProd k r h xs) Source # | |

type ExtensibleConstr k (BitProd k r) h xs x Source # | |

type Rep (BitProd k r h xs) Source # | |

type BitWidth (BitProd k r h xs) Source # | |

class (Bits r, KnownNat (BitWidth a)) => FromBits r a where Source #

Conversion between a value and a bit representation.

Instances of `FromBits`

must satisfy the following laws:

fromBits (x `shiftL` W .|. toBits a) ≡ a toBits a `shiftR` W == zeroBits

where W is the `BitWidth`

.

FromBits Word64 Bool Source # | |

FromBits Word64 Int8 Source # | |

FromBits Word64 Int16 Source # | |

FromBits Word64 Int32 Source # | |

FromBits Word64 Word8 Source # | |

FromBits Word64 Word16 Source # | |

FromBits Word64 Word32 Source # | |

FromBits Word64 Word64 Source # | |

Bits r => FromBits r () Source # | |

FromBits r a => FromBits r (Identity a) Source # | |

(FromBits r a, FromBits r b, (~) Nat n ((+) (BitWidth a) (BitWidth b)), (<=) n (BitWidth r), KnownNat n) => FromBits r (a, b) Source # | |

Bits r => FromBits r (Proxy k a) Source # | |

FromBits r a => FromBits r (Const' k a b) Source # | |

(Bits r, KnownNat (TotalBits k h xs)) => FromBits r (BitProd k r h xs) Source # | |

(Bits r, FromBits r (h (AssocValue k v x))) => FromBits r (Field k v h x) Source # | |

type BitFields r h xs = (FromBits r r, TotalBits h xs <= BitWidth r, Forall (Instance1 (FromBits r) h) xs) Source #

Fields are instances of `FromBits`

and fit in the representation.

blookup :: forall x r h xs. (BitFields r h xs, FromBits r (h x)) => Membership xs x -> BitProd r h xs -> h x Source #

bupdate :: forall x r h xs. (BitFields r h xs, FromBits r (h x)) => Membership xs x -> BitProd r h xs -> h x -> BitProd r h xs Source #

Update a field of a `BitProd`

.

toBitProd :: forall r h xs. BitFields r h xs => (h :* xs) -> BitProd r h xs Source #

Convert a normal extensible record into a bit record.

fromBitProd :: forall r h xs. BitFields r h xs => BitProd r h xs -> h :* xs Source #

Convert a normal extensible record into a bit record.

type BitRecordOf r h = BitProd r (Field h) Source #

Bit-packed record

type BitRecord r = BitRecordOf r Identity Source #

Bit-packed record