ivory-bitdata-0.2.0.0: Ivory bit-data support.

Safe HaskellNone

Ivory.BitData.Bits

Synopsis

Documentation

type family BitRep n :: *Source

Type function: BitRep (n :: Nat) returns an Ivory type given a bit size as a type-level natural. Instances of this type family for bits [1..64] are generated using Template Haskell.

type IvoryRep a = (IvoryBits a, IvoryOrd a, IvoryInit a, IvoryStore a, IvoryType a)Source

Set of constraints we require on a bit representation type.

newtype Bits n Source

A wrapper for an Ivory type that can hold an n bit unsigned integer.

Constructors

Bits 

Fields

unBits :: BitRep n
 

Instances

IvoryRep (BitRep n) => IvoryEq (Bits n) 
IvoryRep (BitRep n) => IvoryType (Bits n) 
IvoryRep (BitRep n) => IvoryVar (Bits n) 
IvoryRep (BitRep n) => IvoryExpr (Bits n) 
(SingI Nat n, IvoryRep (BitRep n)) => BitData (Bits n)

Identity instance of BitData for the base Bits n type.

type Bit = Bits 1Source

Bit is a type alias for Bits 1.

type family BitSize a :: NatSource

Type function to extract the n from a Bits n type.

unsafeIntToBits :: (IvoryRep (BitRep n), Integral a) => a -> Bits nSource

Convert a Haskell integer to a bit data value without bounds checking. This must not be exported, but is used by the quasiquoter when the values are constant at compile-time and already bounds checked.

zeroBits :: IvoryRep (BitRep n) => Bits nSource

Return a bit value of all zeros of the given size.

repToBits :: forall n. (SingI n, IvoryRep (BitRep n)) => BitRep n -> Bits nSource

Convert an Ivory value to a bit value. If the input value contains out of range bits, they will be ignored.

bitsToRep :: Bits n -> BitRep nSource

Convert a bit value to an Ivory value.