extensible-0.4.7.1: Extensible, efficient, optics-friendly data types and effects

Safe HaskellNone
LanguageHaskell2010

Data.Extensible.Bits

Synopsis

Documentation

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

Bit-vector product. It has similar interface as (:*) but fields are packed into r.

Constructors

BitProd 

Fields

Instances

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

Associated Types

type ExtensibleConstr f (t :: (f -> *) -> [f] -> *) (h :: f -> *) (xs :: [f]) (x :: f) :: Constraint Source #

Methods

pieceAt :: ExtensibleConstr f t h xs x => Membership f xs x -> Optic' * * (BitProd k r) p (t h xs) (h x) Source #

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

Associated Types

type BitWidth (BitProd k r h xs) :: Nat Source #

Methods

fromBits :: r -> BitProd k r h xs Source #

toBits :: BitProd k r h xs -> r Source #

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

Methods

minBound :: BitProd k r h xs #

maxBound :: BitProd k r h xs #

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

Methods

succ :: BitProd k r h xs -> BitProd k r h xs #

pred :: BitProd k r h xs -> BitProd k r h xs #

toEnum :: Int -> BitProd k r h xs #

fromEnum :: BitProd k r h xs -> Int #

enumFrom :: BitProd k r h xs -> [BitProd k r h xs] #

enumFromThen :: BitProd k r h xs -> BitProd k r h xs -> [BitProd k r h xs] #

enumFromTo :: BitProd k r h xs -> BitProd k r h xs -> [BitProd k r h xs] #

enumFromThenTo :: BitProd k r h xs -> BitProd k r h xs -> BitProd k r h xs -> [BitProd k r h xs] #

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

Methods

(==) :: BitProd k r h xs -> BitProd k r h xs -> Bool #

(/=) :: BitProd k r h xs -> BitProd k r h xs -> Bool #

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

Methods

compare :: BitProd k r h xs -> BitProd k r h xs -> Ordering #

(<) :: BitProd k r h xs -> BitProd k r h xs -> Bool #

(<=) :: BitProd k r h xs -> BitProd k r h xs -> Bool #

(>) :: BitProd k r h xs -> BitProd k r h xs -> Bool #

(>=) :: BitProd k r h xs -> BitProd k r h xs -> Bool #

max :: BitProd k r h xs -> BitProd k r h xs -> BitProd k r h xs #

min :: BitProd k r h xs -> BitProd k r h xs -> BitProd k r h xs #

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

Methods

showsPrec :: Int -> BitProd k r h xs -> ShowS #

show :: BitProd k r h xs -> String #

showList :: [BitProd k r h xs] -> ShowS #

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

Methods

range :: (BitProd k r h xs, BitProd k r h xs) -> [BitProd k r h xs] #

index :: (BitProd k r h xs, BitProd k r h xs) -> BitProd k r h xs -> Int #

unsafeIndex :: (BitProd k r h xs, BitProd k r h xs) -> BitProd k r h xs -> Int

inRange :: (BitProd k r h xs, BitProd k r h xs) -> BitProd k r h xs -> Bool #

rangeSize :: (BitProd k r h xs, BitProd k r h xs) -> Int #

unsafeRangeSize :: (BitProd k r h xs, BitProd k r h xs) -> Int

Generic (BitProd k r h xs) Source # 

Associated Types

type Rep (BitProd k r h xs) :: * -> * #

Methods

from :: BitProd k r h xs -> Rep (BitProd k r h xs) x #

to :: Rep (BitProd k r h xs) x -> BitProd k r h xs #

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

Methods

sizeOf :: BitProd k r h xs -> Int #

alignment :: BitProd k r h xs -> Int #

peekElemOff :: Ptr (BitProd k r h xs) -> Int -> IO (BitProd k r h xs) #

pokeElemOff :: Ptr (BitProd k r h xs) -> Int -> BitProd k r h xs -> IO () #

peekByteOff :: Ptr b -> Int -> IO (BitProd k r h xs) #

pokeByteOff :: Ptr b -> Int -> BitProd k r h xs -> IO () #

peek :: Ptr (BitProd k r h xs) -> IO (BitProd k r h xs) #

poke :: Ptr (BitProd k r h xs) -> BitProd k r h xs -> IO () #

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

Methods

hashWithSalt :: Int -> BitProd k r h xs -> Int #

hash :: BitProd k r h xs -> Int #

type ExtensibleConstr k (BitProd k r) h xs x Source # 
type ExtensibleConstr k (BitProd k r) h xs x = (BitFields k r h xs, FromBits r (h x))
type Rep (BitProd k r h xs) Source # 
type Rep (BitProd k r h xs) = D1 * (MetaData "BitProd" "Data.Extensible.Bits" "extensible-0.4.7.1-6dMtc2bHm6wkFQI0yFQsC" True) (C1 * (MetaCons "BitProd" PrefixI True) (S1 * (MetaSel (Just Symbol "unBitProd") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * r)))
type BitWidth (BitProd k r h xs) Source # 
type BitWidth (BitProd k r h xs) = TotalBits k h xs

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.

Minimal complete definition

fromBits, toBits

Associated Types

type BitWidth a :: Nat Source #

Methods

fromBits :: r -> a Source #

toBits :: a -> r Source #

Instances

FromBits Word64 Bool Source # 

Associated Types

type BitWidth Bool :: Nat Source #

FromBits Word64 Int8 Source # 

Associated Types

type BitWidth Int8 :: Nat Source #

FromBits Word64 Int16 Source # 

Associated Types

type BitWidth Int16 :: Nat Source #

FromBits Word64 Int32 Source # 

Associated Types

type BitWidth Int32 :: Nat Source #

FromBits Word64 Word8 Source # 

Associated Types

type BitWidth Word8 :: Nat Source #

FromBits Word64 Word16 Source # 

Associated Types

type BitWidth Word16 :: Nat Source #

FromBits Word64 Word32 Source # 

Associated Types

type BitWidth Word32 :: Nat Source #

FromBits Word64 Word64 Source # 

Associated Types

type BitWidth Word64 :: Nat Source #

Bits r => FromBits r () Source # 

Associated Types

type BitWidth () :: Nat Source #

Methods

fromBits :: r -> () Source #

toBits :: () -> r Source #

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

Associated Types

type BitWidth (Identity a) :: Nat Source #

Methods

fromBits :: r -> Identity a Source #

toBits :: Identity a -> r Source #

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

Associated Types

type BitWidth (a, b) :: Nat Source #

Methods

fromBits :: r -> (a, b) Source #

toBits :: (a, b) -> r Source #

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

Associated Types

type BitWidth (Proxy k a) :: Nat Source #

Methods

fromBits :: r -> Proxy k a Source #

toBits :: Proxy k a -> r Source #

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

Associated Types

type BitWidth (Const' k a b) :: Nat Source #

Methods

fromBits :: r -> Const' k a b Source #

toBits :: Const' k a b -> r Source #

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

Associated Types

type BitWidth (BitProd k r h xs) :: Nat Source #

Methods

fromBits :: r -> BitProd k r h xs Source #

toBits :: BitProd k r h xs -> r Source #

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

Associated Types

type BitWidth (Field k v h x) :: Nat Source #

Methods

fromBits :: r -> Field k v h x Source #

toBits :: Field k v h x -> r Source #

type family TotalBits h xs where ... Source #

Equations

TotalBits h '[] = 0 
TotalBits h (x ': xs) = BitWidth (h x) + TotalBits h xs 

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 #