Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data Unum (xs :: [Type])
- class UnumNum a where
- data I (n :: Nat)
- newtype U u = U (BackingWord u)
- data Neg a
- data Rcp a
- type Infinite = Rcp (I 0)
- type family Log2 n where ...
- type family UnumNumbers x where ...
- type family UnumSize x where ...
- type family BackingWord x where ...
- data UBit
- unumSize :: forall u. KnownNat (UnumSize u) => Word
- unumZero :: forall u. (Num (BackingWord u), Bits (BackingWord u), Encodable (I 0) u) => U u
- unumInfinite :: forall u. (Num (BackingWord u), Bits (BackingWord u), Encodable Infinite u) => U u
- unumEncode :: forall u x i. (i ~ IndexOf (Simplify x) (UnumIndexables u), KnownNat i, Num (BackingWord u), Bits (BackingWord u)) => UBit -> U u
- unumBits :: forall u. (Bits (BackingWord u), KnownNat (UnumSize u)) => U u -> String
- unumNegate :: forall u. (Bits (BackingWord u), Num (BackingWord u), KnownNat (UnumSize u)) => U u -> U u
- unumReciprocate :: forall u. (Bits (BackingWord u), Num (BackingWord u), KnownNat (UnumSize u)) => U u -> U u
- unumLabels :: forall u v. (HFoldr' GetLabel [String] v [String], v ~ UnumMembers u) => [String]
- data Sign
- unumSign :: forall u. (Bits (BackingWord u), KnownNat (UnumSize u)) => U u -> Sign
- data SORN u
- type family SORNBackingWord u where ...
- sornBits :: forall u s. (Bits (SORNBackingWord u), KnownNat (UnumSize u), s ~ SORNSize u, KnownNat s) => SORN u -> String
- sornSize :: forall u s. (s ~ SORNSize u, KnownNat s) => Word
- sornEmpty :: Bits (SORNBackingWord u) => SORN u
- sornFull :: forall u. (Bits (SORNBackingWord u), KnownNat (SORNSize u)) => SORN u
- sornNonInfinite :: forall u. (Bits (SORNBackingWord u), Integral (BackingWord u), Bits (BackingWord u), Encodable Infinite u) => SORN u
- sornNonZero :: (Bits (SORNBackingWord u), Integral (BackingWord u), Bits (BackingWord u), Encodable (I 0) u) => SORN u
- sornSingle :: (Integral (BackingWord u), Bits (SORNBackingWord u)) => U u -> SORN u
- sornInsert :: forall u. (Bits (SORNBackingWord u), Integral (BackingWord u)) => SORN u -> U u -> SORN u
- sornMember :: forall u. (Bits (SORNBackingWord u), Integral (BackingWord u)) => SORN u -> U u -> Bool
- sornRemove :: forall u. (Bits (SORNBackingWord u), Integral (BackingWord u)) => SORN u -> U u -> SORN u
- sornUnion :: forall u. Bits (SORNBackingWord u) => SORN u -> SORN u -> SORN u
- sornIntersect :: forall u. Bits (SORNBackingWord u) => SORN u -> SORN u -> SORN u
- sornComplement :: Bits (SORNBackingWord u) => SORN u -> SORN u
- sornNegate :: forall u. (Bits (SORNBackingWord u), Bits (BackingWord u), Integral (BackingWord u), KnownNat (SORNSize u), KnownNat (UnumSize u)) => SORN u -> SORN u
- sornElems :: forall u s. (s ~ SORNSize u, KnownNat s, Bits (SORNBackingWord u), Num (BackingWord u)) => SORN u -> [U u]
- sornFromElems :: (Integral (BackingWord u), Bits (SORNBackingWord u)) => [U u] -> SORN u
- sornFromTo :: forall u. (Integral (BackingWord u), Bits (SORNBackingWord u), Bits (BackingWord u), KnownNat (UnumSize u)) => U u -> U u -> SORN u
- class SornAdd u where
- sornAddU :: U u -> U u -> SORN u
- sornAdd :: (KnownNat (SORNSize u), Bits (SORNBackingWord u), Num (BackingWord u)) => SORN u -> SORN u -> SORN u
- sornAddDep :: (KnownNat (SORNSize u), Bits (SORNBackingWord u), Num (BackingWord u)) => SORN u -> SORN u
- sornSubU :: (Bits (BackingWord u), Num (BackingWord u), KnownNat (UnumSize u)) => U u -> U u -> SORN u
- sornSub :: (KnownNat (SORNSize u), Bits (SORNBackingWord u), Bits (BackingWord u), Num (BackingWord u), KnownNat (UnumSize u)) => SORN u -> SORN u -> SORN u
- sornSubDep :: (KnownNat (SORNSize u), Bits (SORNBackingWord u), Bits (BackingWord u), Num (BackingWord u), KnownNat (UnumSize u)) => SORN u -> SORN u
- newtype CSORN u = CSORN (BitFields (CSORNBackingWord u) '[BitField (UnumSize u) "start" (BackingWord u), BitField (UnumSize u) "count" (BackingWord u)])
- csornSize :: forall u s. (s ~ CSORNSize u, KnownNat s) => Word
- csornBits :: forall u s. (Bits (CSORNBackingWord u), KnownNat (UnumSize u), s ~ CSORNSize u, KnownNat s) => CSORN u -> String
- csornToSorn :: forall u. (KnownNat (UnumSize u), Num (BackingWord u), Integral (BackingWord u), Integral (CSORNBackingWord u), Bits (CSORNBackingWord u), Bits (BackingWord u), Bits (SORNBackingWord u), Field (BackingWord u), KnownNat (SORNSize u), Bits (SORNBackingWord u)) => CSORN u -> SORN u
- csornEmpty :: forall u. Bits (CSORNBackingWord u) => CSORN u
- csornIsEmpty :: forall u. Bits (CSORNBackingWord u) => CSORN u -> Bool
- csornFromTo :: forall u. (Num (BackingWord u), Bits (BackingWord u), KnownNat (UnumSize u), KnownNat (SORNSize u), Bits (BackingWord u), Integral (CSORNBackingWord u), Bits (CSORNBackingWord u), Field (BackingWord u), Integral (BackingWord u)) => U u -> U u -> CSORN u
- csornFull :: forall u. (Bits (CSORNBackingWord u), Integral (CSORNBackingWord u), Integral (BackingWord u), KnownNat (UnumSize u), Field (BackingWord u)) => CSORN u
- csornSingle :: forall u. (Bits (CSORNBackingWord u), Integral (CSORNBackingWord u), Integral (BackingWord u), KnownNat (UnumSize u), Field (BackingWord u)) => U u -> CSORN u
Documentation
data Unum (xs :: [Type]) Source #
An Unum
0 (and its reciprocal) is always included. Numbers have to be >= 1 and sorted.
e.g., Unum '[] => 0 .. 0 .. 0 Unum '[I 1] => 0 .. -1 .. 0 .. 1 .. 0 Unum '[I 1, I 2] => 0 .. -2 .. -1 .. -2 .. 0 .. 2 .. 1 .. 2 .. 0 Unum '[I 1, PI] => 0 .. -PI .. -1 .. -PI .. 0 .. PI .. 1 .. PI .. 0
U (BackingWord u) |
type family UnumNumbers x where ... Source #
Compute the precise numbers set
UnumNumbers (Unum xs) = Nub (AddNeg (AddRcp (Snoc xs Infinite))) |
type family UnumSize x where ... Source #
Compute the number of bits required
UnumSize x = 1 + Log2 (Length (UnumNumbers x)) |
type family BackingWord x where ... Source #
Backing word for the unum
BackingWord x = WordAtLeast (UnumSize x) |
Uncertainty bit
ExactNumber | Exact number |
OpenInterval | OpenInterval above the exact number |
unumZero :: forall u. (Num (BackingWord u), Bits (BackingWord u), Encodable (I 0) u) => U u Source #
Zero
unumInfinite :: forall u. (Num (BackingWord u), Bits (BackingWord u), Encodable Infinite u) => U u Source #
Infinite
unumEncode :: forall u x i. (i ~ IndexOf (Simplify x) (UnumIndexables u), KnownNat i, Num (BackingWord u), Bits (BackingWord u)) => UBit -> U u Source #
Encode a number
unumNegate :: forall u. (Bits (BackingWord u), Num (BackingWord u), KnownNat (UnumSize u)) => U u -> U u Source #
Negate a number
unumReciprocate :: forall u. (Bits (BackingWord u), Num (BackingWord u), KnownNat (UnumSize u)) => U u -> U u Source #
Reciprocate a number
unumLabels :: forall u v. (HFoldr' GetLabel [String] v [String], v ~ UnumMembers u) => [String] Source #
Unum labels
unumSign :: forall u. (Bits (BackingWord u), KnownNat (UnumSize u)) => U u -> Sign Source #
Get unum sign
SORN (bit-sets)
Instances
(KnownNat (SORNSize u), Bits (SORNBackingWord u), Num (BackingWord u), Integral (BackingWord u), HFoldr' GetLabel [String] v [String], v ~ UnumMembers u) => Show (SORN u) Source # | |
type family SORNBackingWord u where ... Source #
SORNBackingWord u = WordAtLeast (SORNSize u) |
sornBits :: forall u s. (Bits (SORNBackingWord u), KnownNat (UnumSize u), s ~ SORNSize u, KnownNat s) => SORN u -> String Source #
Show SORN bits
sornNonInfinite :: forall u. (Bits (SORNBackingWord u), Integral (BackingWord u), Bits (BackingWord u), Encodable Infinite u) => SORN u Source #
Full SORN without infinite
sornNonZero :: (Bits (SORNBackingWord u), Integral (BackingWord u), Bits (BackingWord u), Encodable (I 0) u) => SORN u Source #
Full SORN without infinite
sornSingle :: (Integral (BackingWord u), Bits (SORNBackingWord u)) => U u -> SORN u Source #
SORN singleton
sornInsert :: forall u. (Bits (SORNBackingWord u), Integral (BackingWord u)) => SORN u -> U u -> SORN u Source #
Insert in a SORN
sornMember :: forall u. (Bits (SORNBackingWord u), Integral (BackingWord u)) => SORN u -> U u -> Bool Source #
Test membership in a SORN
sornRemove :: forall u. (Bits (SORNBackingWord u), Integral (BackingWord u)) => SORN u -> U u -> SORN u Source #
Remove in a SORN
sornUnion :: forall u. Bits (SORNBackingWord u) => SORN u -> SORN u -> SORN u Source #
Union of two SORNs
sornIntersect :: forall u. Bits (SORNBackingWord u) => SORN u -> SORN u -> SORN u Source #
Intersection of two SORNs
sornComplement :: Bits (SORNBackingWord u) => SORN u -> SORN u Source #
Complement the SORN
sornNegate :: forall u. (Bits (SORNBackingWord u), Bits (BackingWord u), Integral (BackingWord u), KnownNat (SORNSize u), KnownNat (UnumSize u)) => SORN u -> SORN u Source #
Negate a SORN
sornElems :: forall u s. (s ~ SORNSize u, KnownNat s, Bits (SORNBackingWord u), Num (BackingWord u)) => SORN u -> [U u] Source #
Elements in the SORN
sornFromElems :: (Integral (BackingWord u), Bits (SORNBackingWord u)) => [U u] -> SORN u Source #
Create a SORN from its elements
sornFromTo :: forall u. (Integral (BackingWord u), Bits (SORNBackingWord u), Bits (BackingWord u), KnownNat (UnumSize u)) => U u -> U u -> SORN u Source #
Create a contiguous SORN from two elements
class SornAdd u where Source #
sornAddU :: U u -> U u -> SORN u Source #
Add two Unums
sornAdd :: (KnownNat (SORNSize u), Bits (SORNBackingWord u), Num (BackingWord u)) => SORN u -> SORN u -> SORN u Source #
Add two SORNs
sornAddDep :: (KnownNat (SORNSize u), Bits (SORNBackingWord u), Num (BackingWord u)) => SORN u -> SORN u Source #
Add a SORN with itself
sornSubU :: (Bits (BackingWord u), Num (BackingWord u), KnownNat (UnumSize u)) => U u -> U u -> SORN u Source #
Subtract two Unums
sornSub :: (KnownNat (SORNSize u), Bits (SORNBackingWord u), Bits (BackingWord u), Num (BackingWord u), KnownNat (UnumSize u)) => SORN u -> SORN u -> SORN u Source #
Subtract two SORNS
sornSubDep :: (KnownNat (SORNSize u), Bits (SORNBackingWord u), Bits (BackingWord u), Num (BackingWord u), KnownNat (UnumSize u)) => SORN u -> SORN u Source #
Subtract a SORN with itself
Contiguous SORN
CSORN (BitFields (CSORNBackingWord u) '[BitField (UnumSize u) "start" (BackingWord u), BitField (UnumSize u) "count" (BackingWord u)]) |
Instances
(KnownNat (SORNSize u), KnownNat (UnumSize u), Bits (BackingWord u), Bits (CSORNBackingWord u), Integral (CSORNBackingWord u), Num (BackingWord u), Integral (BackingWord u), HFoldr' GetLabel [String] v [String], Field (BackingWord u), Bits (SORNBackingWord u), Bits (SORNBackingWord u), v ~ UnumMembers u) => Show (CSORN u) Source # | |
csornSize :: forall u s. (s ~ CSORNSize u, KnownNat s) => Word Source #
Size of a contiguous SORN in bits
csornBits :: forall u s. (Bits (CSORNBackingWord u), KnownNat (UnumSize u), s ~ CSORNSize u, KnownNat s) => CSORN u -> String Source #
Show contiguous SORN bits
csornToSorn :: forall u. (KnownNat (UnumSize u), Num (BackingWord u), Integral (BackingWord u), Integral (CSORNBackingWord u), Bits (CSORNBackingWord u), Bits (BackingWord u), Bits (SORNBackingWord u), Field (BackingWord u), KnownNat (SORNSize u), Bits (SORNBackingWord u)) => CSORN u -> SORN u Source #
Convert a contiguous SORN into a SORN
csornEmpty :: forall u. Bits (CSORNBackingWord u) => CSORN u Source #
Empty contigiuous SORN
csornIsEmpty :: forall u. Bits (CSORNBackingWord u) => CSORN u -> Bool Source #
Test if a contigiuous SORN is empty
csornFromTo :: forall u. (Num (BackingWord u), Bits (BackingWord u), KnownNat (UnumSize u), KnownNat (SORNSize u), Bits (BackingWord u), Integral (CSORNBackingWord u), Bits (CSORNBackingWord u), Field (BackingWord u), Integral (BackingWord u)) => U u -> U u -> CSORN u Source #
Contiguous SORN build
csornFull :: forall u. (Bits (CSORNBackingWord u), Integral (CSORNBackingWord u), Integral (BackingWord u), KnownNat (UnumSize u), Field (BackingWord u)) => CSORN u Source #
Full contiguous SORN
csornSingle :: forall u. (Bits (CSORNBackingWord u), Integral (CSORNBackingWord u), Integral (BackingWord u), KnownNat (UnumSize u), Field (BackingWord u)) => U u -> CSORN u Source #
Contiguous SORN singleton