Copyright | (C) 2017-2018 mniip |
---|---|
License | MIT |
Maintainer | mniip@mniip.com |
Stability | stable |
Portability | portable |
Safe Haskell | Trustworthy |
Language | Haskell2010 |
Synopsis
- class NatSingleton (p :: Nat -> *) where
- data NatIsZero (n :: Nat) where
- data NatPeano (n :: Nat) where
- data NatTwosComp (n :: Nat) where
- TwosCompZero :: NatTwosComp 0
- TwosCompx2p1 :: KnownNat n => NatTwosComp n -> NatTwosComp (1 + (2 * n))
- TwosCompx2p2 :: KnownNat n => NatTwosComp n -> NatTwosComp (2 + (2 * n))
- data NatBaseComp (p :: Nat -> *) (b :: Nat) (n :: Nat) where
- BaseCompZero :: (KnownNat b, b ~ (1 + c)) => NatBaseComp p b 0
- BaseCompxBp1p :: (KnownNat b, b ~ (1 + c), KnownNat k, (1 + k) <= b, KnownNat n) => p k -> NatBaseComp p b n -> NatBaseComp p b ((1 + k) + (b * n))
- class PositiveSingleton (p :: Nat -> *) where
- data Unary (n :: Nat) where
- data PosBinary (n :: Nat) where
- data PosBase (p :: Nat -> *) (b :: Nat) (n :: Nat) where
- class ShowN (p :: Nat -> *) where
Natural number singletons
class NatSingleton (p :: Nat -> *) where Source #
A class of singletons capable of representing any KnownNat
natural number.
natSingleton :: KnownNat n => p n Source #
Instances
NatSingleton NatTwosComp Source # | |
Defined in GHC.TypeLits.Singletons natSingleton :: KnownNat n => NatTwosComp n Source # | |
NatSingleton NatPeano Source # | |
Defined in GHC.TypeLits.Singletons natSingleton :: KnownNat n => NatPeano n Source # | |
NatSingleton NatIsZero Source # | |
Defined in GHC.TypeLits.Singletons natSingleton :: KnownNat n => NatIsZero n Source # | |
NatSingleton (Proxy :: Nat -> *) Source # | |
Defined in GHC.TypeLits.Singletons natSingleton :: KnownNat n => Proxy n Source # | |
(KnownNat b, b ~ (1 + c), NatSingleton p) => NatSingleton (NatBaseComp p b) Source # | |
Defined in GHC.TypeLits.Singletons natSingleton :: KnownNat n => NatBaseComp p b n Source # |
data NatIsZero (n :: Nat) where Source #
A natural number is either 0 or 1 plus something.
Instances
ShowN NatIsZero Source # | |
Defined in GHC.TypeLits.Singletons | |
NatSingleton NatIsZero Source # | |
Defined in GHC.TypeLits.Singletons natSingleton :: KnownNat n => NatIsZero n Source # | |
Show (NatIsZero n) Source # | |
data NatPeano (n :: Nat) where Source #
A natural number is either 0 or a successor of another natural number.
For example, 3 = 1 + (1 + (1 + 0))
:
PeanoSucc (PeanoSucc (PeanoSucc PeanoZero)) :: NatPeano 3
Instances
ShowN NatPeano Source # | |
Defined in GHC.TypeLits.Singletons | |
NatSingleton NatPeano Source # | |
Defined in GHC.TypeLits.Singletons natSingleton :: KnownNat n => NatPeano n Source # | |
Show (NatPeano n) Source # | |
data NatTwosComp (n :: Nat) where Source #
A natural number is either 0, or twice another natural number plus 1 or 2.
For example, 12 = 2 + 2 * (1 + 2 * (2 + 2 * 0))
:
TwosCompx2p2 (TwosCompx2p1 (TwosCompx2p2 TwosCompZero)) :: NatTwosComp 12
TwosCompZero :: NatTwosComp 0 | |
TwosCompx2p1 :: KnownNat n => NatTwosComp n -> NatTwosComp (1 + (2 * n)) | |
TwosCompx2p2 :: KnownNat n => NatTwosComp n -> NatTwosComp (2 + (2 * n)) |
Instances
ShowN NatTwosComp Source # | |
Defined in GHC.TypeLits.Singletons showsPrecN :: Int -> NatTwosComp n -> ShowS Source # | |
NatSingleton NatTwosComp Source # | |
Defined in GHC.TypeLits.Singletons natSingleton :: KnownNat n => NatTwosComp n Source # | |
Show (NatTwosComp n) Source # | |
Defined in GHC.TypeLits.Singletons showsPrec :: Int -> NatTwosComp n -> ShowS # show :: NatTwosComp n -> String # showList :: [NatTwosComp n] -> ShowS # |
data NatBaseComp (p :: Nat -> *) (b :: Nat) (n :: Nat) where Source #
A natural number is either 0, or b
times another natural number plus a digit in [1, b]
.
For example, 123 = (2 + 1) + 10 * ((1 + 1) + 10 * ((0 + 1) + 10 * 0))
:
BaseCompxBp1p (natSingleton :: p 2) (BaseCompxBp1p (natSingleton :: p 1) (BaseCompxBp1p (natSingleton :: p 0) BaseCompZero)) :: NatBaseComp p 10 123
BaseCompZero :: (KnownNat b, b ~ (1 + c)) => NatBaseComp p b 0 | |
BaseCompxBp1p :: (KnownNat b, b ~ (1 + c), KnownNat k, (1 + k) <= b, KnownNat n) => p k -> NatBaseComp p b n -> NatBaseComp p b ((1 + k) + (b * n)) |
Instances
ShowN p => ShowN (NatBaseComp p b) Source # | |
Defined in GHC.TypeLits.Singletons showsPrecN :: Int -> NatBaseComp p b n -> ShowS Source # | |
(KnownNat b, b ~ (1 + c), NatSingleton p) => NatSingleton (NatBaseComp p b) Source # | |
Defined in GHC.TypeLits.Singletons natSingleton :: KnownNat n => NatBaseComp p b n Source # | |
ShowN p => Show (NatBaseComp p b n) Source # | |
Defined in GHC.TypeLits.Singletons showsPrec :: Int -> NatBaseComp p b n -> ShowS # show :: NatBaseComp p b n -> String # showList :: [NatBaseComp p b n] -> ShowS # |
Positive number singleton
class PositiveSingleton (p :: Nat -> *) where Source #
A class of singletons capable of representing postive KnownNat
natural numbers.
posSingleton :: KnownNat n => p (1 + n) Source #
Instances
PositiveSingleton PosBinary Source # | |
Defined in GHC.TypeLits.Singletons | |
PositiveSingleton Unary Source # | |
Defined in GHC.TypeLits.Singletons | |
PositiveSingleton (Proxy :: Nat -> *) Source # | |
Defined in GHC.TypeLits.Singletons | |
(KnownNat b, b ~ (2 + c), NatSingleton p) => PositiveSingleton (PosBase p b) Source # | |
Defined in GHC.TypeLits.Singletons |
data Unary (n :: Nat) where Source #
A positive number is either 1 or a successor of another positive number.
For example, 5 = 1 + (1 + (1 + (1 + 1)))
:
UnarySucc (UnarySucc (UnarySucc (UnarySucc UnaryOne))) :: Unary 5
Instances
PositiveSingleton Unary Source # | |
Defined in GHC.TypeLits.Singletons | |
ShowN Unary Source # | |
Defined in GHC.TypeLits.Singletons | |
Show (Unary n) Source # | |
data PosBinary (n :: Nat) where Source #
A positive number is either 1, or twice another positive number plus 0 or 1.
For example, 10 = 0 + 2 * (1 + 2 * (0 + 2 * 1))
:
Bin0 (Bin1 (Bin0 BinOne)) :: PosBinary 10
BinOne :: PosBinary 1 | |
Bin0 :: KnownNat n => PosBinary n -> PosBinary (2 * n) | |
Bin1 :: KnownNat n => PosBinary n -> PosBinary (1 + (2 * n)) |
Instances
PositiveSingleton PosBinary Source # | |
Defined in GHC.TypeLits.Singletons | |
ShowN PosBinary Source # | |
Defined in GHC.TypeLits.Singletons | |
Show (PosBinary n) Source # | |
data PosBase (p :: Nat -> *) (b :: Nat) (n :: Nat) where Source #
A positive number is either a digit in [1, b)
, or another positive number times b
plus a digit in [0, b)
.
For example, 123 = 3 + 10 * (2 + 10 * 1)
:
BaseDigit (natSingleton :: p 3) (BaseDigit (natSingleton :: p 2) (BaseLead (natSingleton :: p 1))) :: PosBase p 10 123
BaseLead :: (KnownNat k, (1 + k) <= b, k ~ (1 + n)) => p k -> PosBase p b k | |
BaseDigit :: (KnownNat k, (1 + k) <= b, KnownNat n) => p k -> PosBase p b n -> PosBase p b (k + (b * n)) |
Instances
(KnownNat b, b ~ (2 + c), NatSingleton p) => PositiveSingleton (PosBase p b) Source # | |
Defined in GHC.TypeLits.Singletons | |
ShowN p => ShowN (PosBase p b) Source # | |
Defined in GHC.TypeLits.Singletons | |
ShowN p => Show (PosBase p b n) Source # | |
class ShowN (p :: Nat -> *) where Source #
Auxiliary class for implementing Show
on higher-kinded singletons.
showsPrecN :: Int -> p n -> ShowS Source #
Instances
ShowN PosBinary Source # | |
Defined in GHC.TypeLits.Singletons | |
ShowN Unary Source # | |
Defined in GHC.TypeLits.Singletons | |
ShowN NatTwosComp Source # | |
Defined in GHC.TypeLits.Singletons showsPrecN :: Int -> NatTwosComp n -> ShowS Source # | |
ShowN NatPeano Source # | |
Defined in GHC.TypeLits.Singletons | |
ShowN NatIsZero Source # | |
Defined in GHC.TypeLits.Singletons | |
ShowN (Proxy :: Nat -> *) Source # | |
Defined in GHC.TypeLits.Singletons | |
ShowN p => ShowN (PosBase p b) Source # | |
Defined in GHC.TypeLits.Singletons | |
ShowN p => ShowN (NatBaseComp p b) Source # | |
Defined in GHC.TypeLits.Singletons showsPrecN :: Int -> NatBaseComp p b n -> ShowS Source # |