Safe Haskell | None |
---|---|
Language | GHC2021 |
Data.Type.Nat.Singleton.Fast
Synopsis
- data SNat (n :: Nat) where
- fromSNat :: forall i (n :: Nat). Integral i => SNat n -> i
- fromSNatRaw :: forall (n :: Nat). SNat n -> SNatRep
- plus :: forall (n :: Nat) (m :: Nat). SNat n -> SNat m -> SNat (n + m)
- decSNat :: forall (n :: Nat) (m :: Nat). SNat n -> SNat m -> Maybe (n :~: m)
- data SomeSNat = SomeSNat !(SNat n)
- withSomeSNat :: (forall (n :: Nat). SNat n -> a) -> SomeSNat -> a
- toSomeSNat :: Integral i => i -> SomeSNat
- toSomeSNatRaw :: SNatRep -> SomeSNat
- fromSomeSNat :: Integral i => SomeSNat -> i
- fromSomeSNatRaw :: SomeSNat -> SNatRep
- plusUnitL :: forall (n :: Nat). Proxy n -> ('Z + n) :~: n
- plusUnitR :: forall (n :: Nat). SNat n -> (n + 'Z) :~: n
- plusCommS :: forall (n :: Nat) (m :: Nat). SNat n -> Proxy m -> 'S (n + m) :~: (n + 'S m)
- plusComm :: forall (n :: Nat) (m :: Nat). SNat n -> SNat m -> (n + m) :~: (m + n)
- plusAssoc :: forall (n :: Nat) (m :: Nat) (l :: Nat). SNat n -> Proxy m -> Proxy l -> ((n + m) + l) :~: (n + (m + l))
- class KnownNat (n :: Nat) where
- withKnownNat :: forall (n :: Nat) r. SNat n -> (KnownNat n => r) -> r
- type SNatRep = Int
- intToSNatRep :: Int -> SNatRep
- snatRepToInt :: SNatRep -> Int
- newtype SNat (n :: Nat) = UnsafeSNat {}
Natural Number Singletons
data SNat (n :: Nat) where Source #
is the singleton type for natural numbers.SNat
n
Bundled Patterns
pattern Z :: () => n ~ 'Z => SNat n | |
pattern S :: () => Pos n => SNat (Pred n) -> SNat n |
fromSNat :: forall i (n :: Nat). Integral i => SNat n -> i Source #
returns the numeric representation of 'SNat n'.fromSNat
n
fromSNatRaw :: forall (n :: Nat). SNat n -> SNatRep Source #
returns the raw underlying representation of 'SNat n'.fromSNatRaw
n
plus :: forall (n :: Nat) (m :: Nat). SNat n -> SNat m -> SNat (n + m) Source #
Addition for natural number singletons.
decSNat :: forall (n :: Nat) (m :: Nat). SNat n -> SNat m -> Maybe (n :~: m) Source #
Decidable equality for natural number singletons.
Existential Wrapper
An existential wrapper around natural number singletons.
withSomeSNat :: (forall (n :: Nat). SNat n -> a) -> SomeSNat -> a Source #
Evaluate a term with access to the underlying
.SNat
toSomeSNat :: Integral i => i -> SomeSNat Source #
constructs the singleton toSomeSNat
n
.SNat
n
toSomeSNat (fromSomeSNat n) == n
toSomeSNatRaw :: SNatRep -> SomeSNat Source #
constructs the singleton toSomeSNat
n
.SNat
n
toSomeSNatRaw (fromSomeSNatRaw n) == n
fromSomeSNat :: Integral i => SomeSNat -> i Source #
returns the numeric representation of the wrapped singleton.fromSomeSNat
n
fromSomeSNatRaw :: SomeSNat -> SNatRep Source #
returns the numeric representation of the wrapped singleton.fromSomeSNat
n
Laws
plusAssoc :: forall (n :: Nat) (m :: Nat) (l :: Nat). SNat n -> Proxy m -> Proxy l -> ((n + m) + l) :~: (n + (m + l)) Source #