ivory-0.1.0.3: Safe embedded C programming.

Safe HaskellNone
LanguageHaskell2010

Ivory.Language.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.

Instances

type BitRep 1 = Uint8 Source 
type BitRep 2 = Uint8 Source 
type BitRep 3 = Uint8 Source 
type BitRep 4 = Uint8 Source 
type BitRep 5 = Uint8 Source 
type BitRep 6 = Uint8 Source 
type BitRep 7 = Uint8 Source 
type BitRep 8 = Uint8 Source 
type BitRep 9 = Uint16 Source 
type BitRep 10 = Uint16 Source 
type BitRep 11 = Uint16 Source 
type BitRep 12 = Uint16 Source 
type BitRep 13 = Uint16 Source 
type BitRep 14 = Uint16 Source 
type BitRep 15 = Uint16 Source 
type BitRep 16 = Uint16 Source 
type BitRep 17 = Uint32 Source 
type BitRep 18 = Uint32 Source 
type BitRep 19 = Uint32 Source 
type BitRep 20 = Uint32 Source 
type BitRep 21 = Uint32 Source 
type BitRep 22 = Uint32 Source 
type BitRep 23 = Uint32 Source 
type BitRep 24 = Uint32 Source 
type BitRep 25 = Uint32 Source 
type BitRep 26 = Uint32 Source 
type BitRep 27 = Uint32 Source 
type BitRep 28 = Uint32 Source 
type BitRep 29 = Uint32 Source 
type BitRep 30 = Uint32 Source 
type BitRep 31 = Uint32 Source 
type BitRep 32 = Uint32 Source 
type BitRep 33 = Uint64 Source 
type BitRep 34 = Uint64 Source 
type BitRep 35 = Uint64 Source 
type BitRep 36 = Uint64 Source 
type BitRep 37 = Uint64 Source 
type BitRep 38 = Uint64 Source 
type BitRep 39 = Uint64 Source 
type BitRep 40 = Uint64 Source 
type BitRep 41 = Uint64 Source 
type BitRep 42 = Uint64 Source 
type BitRep 43 = Uint64 Source 
type BitRep 44 = Uint64 Source 
type BitRep 45 = Uint64 Source 
type BitRep 46 = Uint64 Source 
type BitRep 47 = Uint64 Source 
type BitRep 48 = Uint64 Source 
type BitRep 49 = Uint64 Source 
type BitRep 50 = Uint64 Source 
type BitRep 51 = Uint64 Source 
type BitRep 52 = Uint64 Source 
type BitRep 53 = Uint64 Source 
type BitRep 54 = Uint64 Source 
type BitRep 55 = Uint64 Source 
type BitRep 56 = Uint64 Source 
type BitRep 57 = Uint64 Source 
type BitRep 58 = Uint64 Source 
type BitRep 59 = Uint64 Source 
type BitRep 60 = Uint64 Source 
type BitRep 61 = Uint64 Source 
type BitRep 62 = Uint64 Source 
type BitRep 63 = Uint64 Source 
type BitRep 64 = Uint64 Source 

type IvoryRep a = (IvoryBits a, IvoryOrd a, IvoryInit a, IvoryStore a, IvoryType a, IvoryZeroVal 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) => IvoryExpr (Bits n) Source 
IvoryRep (BitRep n) => IvoryVar (Bits n) Source 
IvoryRep (BitRep n) => IvoryType (Bits n) Source 
IvoryRep (BitRep n) => IvoryEq (Bits n) Source 
IvoryRep (BitRep n) => IvoryStore (Bits n) Source 
IvoryRep (BitRep n) => IvoryZeroVal (Bits n) Source 
IvoryRep (BitRep n) => IvoryInit (Bits n) Source 
(ANat n, IvoryRep (BitRep n)) => BitData (Bits n) Source

Identity instance of BitData for the base "Bits n" type.

type BitSize (Bits n) = n Source 
type BitType (Bits n) = Bits n Source 

type Bit = Bits 1 Source

Bit is a type alias for "Bits 1".

type family BitSize a :: Nat Source

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

Instances

type BitSize (Bits n) = n Source 

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

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 n Source

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

repToBits :: forall n. (ANat n, IvoryRep (BitRep n)) => BitRep n -> Bits n Source

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 n Source

Convert a bit value to an Ivory value.