Copyright | (c) Fumiaki Kinoshita 2018 |
---|---|
License | BSD3 |
Maintainer | Fumiaki Kinoshita <fumiexcel@gmail.com> |
Safe Haskell | None |
Language | Haskell2010 |
Data.Extensible.Bits
Description
Bit-packed records
Synopsis
- newtype BitProd r (xs :: [k]) (h :: k -> Type) = BitProd {
- unBitProd :: r
- class (Bits r, KnownNat (BitWidth a)) => FromBits r a where
- type family TotalBits h xs where ...
- type BitFields r xs h = (FromBits r r, TotalBits h xs <= BitWidth r, Forall (Instance1 (FromBits r) h) xs)
- blookup :: forall x r xs h. (BitFields r xs h, FromBits r (h x)) => Membership xs x -> BitProd r xs h -> h x
- bupdate :: forall x r xs h. (BitFields r xs h, FromBits r (h x)) => Membership xs x -> BitProd r xs h -> h x -> BitProd r xs h
- toBitProd :: forall r xs h. BitFields r xs h => (xs :& h) -> BitProd r xs h
- fromBitProd :: forall r xs h. BitFields r xs h => BitProd r xs h -> xs :& h
- type BitRecordOf r h xs = BitProd r xs (Field h)
- type BitRecord r xs = BitRecordOf r Identity xs
Documentation
newtype BitProd r (xs :: [k]) (h :: k -> Type) Source #
Bit-vector product. It has similar interface as (:*)
but fields are packed into r
.
Instances
(Corepresentable p, Comonad (Corep p), Functor f) => Extensible f p (BitProd r :: [k] -> (k -> Type) -> Type) Source # | |
Defined in Data.Extensible.Bits Associated Types type ExtensibleConstr (BitProd r) xs h x :: Constraint Source # Methods pieceAt :: ExtensibleConstr (BitProd r) xs h x => Membership xs x -> Optic' p f (BitProd r xs h) (h x) Source # | |
(Bits r, KnownNat (TotalBits h xs)) => FromBits r (BitProd r xs h) Source # | |
Bounded r => Bounded (BitProd r xs h) Source # | |
Enum r => Enum (BitProd r xs h) Source # | |
Defined in Data.Extensible.Bits Methods succ :: BitProd r xs h -> BitProd r xs h # pred :: BitProd r xs h -> BitProd r xs h # toEnum :: Int -> BitProd r xs h # fromEnum :: BitProd r xs h -> Int # enumFrom :: BitProd r xs h -> [BitProd r xs h] # enumFromThen :: BitProd r xs h -> BitProd r xs h -> [BitProd r xs h] # enumFromTo :: BitProd r xs h -> BitProd r xs h -> [BitProd r xs h] # enumFromThenTo :: BitProd r xs h -> BitProd r xs h -> BitProd r xs h -> [BitProd r xs h] # | |
Eq r => Eq (BitProd r xs h) Source # | |
Ord r => Ord (BitProd r xs h) Source # | |
Defined in Data.Extensible.Bits Methods compare :: BitProd r xs h -> BitProd r xs h -> Ordering # (<) :: BitProd r xs h -> BitProd r xs h -> Bool # (<=) :: BitProd r xs h -> BitProd r xs h -> Bool # (>) :: BitProd r xs h -> BitProd r xs h -> Bool # (>=) :: BitProd r xs h -> BitProd r xs h -> Bool # | |
(Forall (Instance1 Show h) xs, BitFields r xs h) => Show (BitProd r xs h) Source # | |
Ix r => Ix (BitProd r xs h) Source # | |
Defined in Data.Extensible.Bits Methods range :: (BitProd r xs h, BitProd r xs h) -> [BitProd r xs h] # index :: (BitProd r xs h, BitProd r xs h) -> BitProd r xs h -> Int # unsafeIndex :: (BitProd r xs h, BitProd r xs h) -> BitProd r xs h -> Int inRange :: (BitProd r xs h, BitProd r xs h) -> BitProd r xs h -> Bool # rangeSize :: (BitProd r xs h, BitProd r xs h) -> Int # unsafeRangeSize :: (BitProd r xs h, BitProd r xs h) -> Int | |
Generic (BitProd r xs h) Source # | |
Storable r => Storable (BitProd r xs h) Source # | |
Defined in Data.Extensible.Bits Methods sizeOf :: BitProd r xs h -> Int # alignment :: BitProd r xs h -> Int # peekElemOff :: Ptr (BitProd r xs h) -> Int -> IO (BitProd r xs h) # pokeElemOff :: Ptr (BitProd r xs h) -> Int -> BitProd r xs h -> IO () # peekByteOff :: Ptr b -> Int -> IO (BitProd r xs h) # pokeByteOff :: Ptr b -> Int -> BitProd r xs h -> IO () # | |
Hashable r => Hashable (BitProd r xs h) Source # | |
Defined in Data.Extensible.Bits | |
type ExtensibleConstr (BitProd r :: [k] -> (k -> Type) -> Type) (xs :: [k]) (h :: k -> Type) (x :: k) Source # | |
Defined in Data.Extensible.Bits | |
type Rep (BitProd r xs h) Source # | |
Defined in Data.Extensible.Bits | |
type BitWidth (BitProd r xs h) Source # | |
Defined in Data.Extensible.Bits |
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
.
Instances
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, n ~ (BitWidth a + BitWidth b), n <= BitWidth r, KnownNat n) => FromBits r (a, b) Source # | |
Bits r => FromBits r (Proxy a) Source # | |
FromBits r a => FromBits r (Const a b) Source # | |
(Bits r, KnownNat (TotalBits h xs)) => FromBits r (BitProd r xs h) Source # | |
(Bits r, FromBits r (h (TargetOf x))) => FromBits r (Field h x) Source # | |
type BitFields r xs h = (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 xs h. (BitFields r xs h, FromBits r (h x)) => Membership xs x -> BitProd r xs h -> h x Source #
bupdate :: forall x r xs h. (BitFields r xs h, FromBits r (h x)) => Membership xs x -> BitProd r xs h -> h x -> BitProd r xs h Source #
Update a field of a BitProd
.
toBitProd :: forall r xs h. BitFields r xs h => (xs :& h) -> BitProd r xs h Source #
Convert a normal extensible record into a bit record.
fromBitProd :: forall r xs h. BitFields r xs h => BitProd r xs h -> xs :& h Source #
Convert a normal extensible record into a bit record.
type BitRecordOf r h xs = BitProd r xs (Field h) Source #
Bit-packed record
type BitRecord r xs = BitRecordOf r Identity xs Source #
Bit-packed record