Copyright | (C) 2013 Richard Eisenberg |
---|---|
License | BSD-style (see LICENSE) |
Maintainer | Richard Eisenberg (eir@cis.upenn.edu) |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
This module defines a datatype and operations to represent type-level
integers. Though it's defined as part of the units package, it may be
useful beyond dimensional analysis. If you have a compelling non-units
use of this package, please let me (Richard, eir
at cis.upenn.edu
)
know.
- data Z
- data family Sing a
- type SZ z = Sing z
- type ZeroSym0 = Zero
- data SSym0 l
- type SSym1 t = S t
- data PSym0 l
- type PSym1 t = P t
- zToInt :: Z -> Int
- szToInt :: Sing (z :: Z) -> Int
- type family Succ z :: Z
- type family Pred z :: Z
- type family Negate z :: Z
- type family a #+ b :: Z
- type family a #- b :: Z
- type family a #* b :: Z
- type family a #/ b :: Z
- sSucc :: Sing z -> Sing (Succ z)
- sPred :: Sing z -> Sing (Pred z)
- sNegate :: Sing z -> Sing (Negate z)
- type family a < b :: Bool
- type family NonNegative z :: Constraint
- type One = S Zero
- type Two = S One
- type Three = S Two
- type Four = S Three
- type Five = S Four
- type MOne = P Zero
- type MTwo = P MOne
- type MThree = P MTwo
- type MFour = P MThree
- type MFive = P MFour
- sZero :: Sing Z Zero
- sOne :: Sing Z (S Zero)
- sTwo :: Sing Z (S (S Zero))
- sThree :: Sing Z (S (S (S Zero)))
- sFour :: Sing Z (S (S (S (S Zero))))
- sFive :: Sing Z (S (S (S (S (S Zero)))))
- sMOne :: Sing Z (P Zero)
- sMTwo :: Sing Z (P (P Zero))
- sMThree :: Sing Z (P (P (P Zero)))
- sMFour :: Sing Z (P (P (P (P Zero))))
- sMFive :: Sing Z (P (P (P (P (P Zero)))))
- pZero :: Sing Z Zero
- pOne :: Sing Z (S Zero)
- pTwo :: Sing Z (S (S Zero))
- pThree :: Sing Z (S (S (S Zero)))
- pFour :: Sing Z (S (S (S (S Zero))))
- pFive :: Sing Z (S (S (S (S (S Zero)))))
- pMOne :: Sing Z (P Zero)
- pMTwo :: Sing Z (P (P Zero))
- pMThree :: Sing Z (P (P (P Zero)))
- pMFour :: Sing Z (P (P (P (P Zero))))
- pMFive :: Sing Z (P (P (P (P (P Zero)))))
- pSucc :: Sing Z z -> Sing Z (Succ z)
- pPred :: Sing Z z -> Sing Z (Pred z)
The Z
datatype
The datatype for type-level integers.
Eq Z | |
SingI Z Zero | |
SEq Z (KProxy Z) | |
PEq Z (KProxy Z) | |
SDecide Z (KProxy Z) | |
SingI Z n0 => SingI Z (P n) | |
SingI Z n0 => SingI Z (S n) | |
SingKind Z (KProxy Z) | |
SuppressUnusedWarnings (TyFun Z Z -> *) PSym0 | |
SuppressUnusedWarnings (TyFun Z Z -> *) SSym0 | |
data Sing Z where | |
type (:==) Z a0 b0 | |
type Apply Z Z PSym0 l0 = PSym1 l0 | |
type Apply Z Z SSym0 l0 = SSym1 l0 | |
type DemoteRep Z (KProxy Z) = Z |
data family Sing a
The singleton kind-indexed data family.
SDecide k (KProxy k) => TestEquality k (Sing k) | |
data Sing Bool where | |
data Sing Ordering where | |
data Sing Nat where | |
data Sing Symbol where
| |
data Sing () where | |
data Sing Z where | |
data Sing [a0] where | |
data Sing (Maybe a0) where | |
data Sing (TyFun k1 k2 -> *) = SLambda {} | |
data Sing (Either a0 b0) where | |
data Sing ((,) a0 b0) where | |
data Sing ((,,) a0 b0 c0) where | |
data Sing ((,,,) a0 b0 c0 d0) where | |
data Sing ((,,,,) a0 b0 c0 d0 e0) where | |
data Sing ((,,,,,) a0 b0 c0 d0 e0 f0) where | |
data Sing ((,,,,,,) a0 b0 c0 d0 e0 f0 g0) where |
Defunctionalization symbols (these can be ignored)
Conversions
Type-level operations
Arithmetic
Comparisons
type family NonNegative z :: Constraint Source
Check if a type-level integer is in fact a natural number
NonNegative Zero = () | |
NonNegative (S z) = () |
Synonyms for certain numbers
This is the singleton value representing Zero
at the term level and
at the type level, simultaneously. Used for raising units to powers.
Deprecated synonyms
Deprecated: The singleton prefix is changing from p
to s
. The p
versions will be removed in a future release.
pOne :: Sing Z (S Zero) Source
Deprecated: The singleton prefix is changing from p
to s
. The p
versions will be removed in a future release.
pTwo :: Sing Z (S (S Zero)) Source
Deprecated: The singleton prefix is changing from p
to s
. The p
versions will be removed in a future release.
pThree :: Sing Z (S (S (S Zero))) Source
Deprecated: The singleton prefix is changing from p
to s
. The p
versions will be removed in a future release.
pFour :: Sing Z (S (S (S (S Zero)))) Source
Deprecated: The singleton prefix is changing from p
to s
. The p
versions will be removed in a future release.
pFive :: Sing Z (S (S (S (S (S Zero))))) Source
Deprecated: The singleton prefix is changing from p
to s
. The p
versions will be removed in a future release.
pMOne :: Sing Z (P Zero) Source
Deprecated: The singleton prefix is changing from p
to s
. The p
versions will be removed in a future release.
pMTwo :: Sing Z (P (P Zero)) Source
Deprecated: The singleton prefix is changing from p
to s
. The p
versions will be removed in a future release.
pMThree :: Sing Z (P (P (P Zero))) Source
Deprecated: The singleton prefix is changing from p
to s
. The p
versions will be removed in a future release.
pMFour :: Sing Z (P (P (P (P Zero)))) Source
Deprecated: The singleton prefix is changing from p
to s
. The p
versions will be removed in a future release.
pMFive :: Sing Z (P (P (P (P (P Zero))))) Source
Deprecated: The singleton prefix is changing from p
to s
. The p
versions will be removed in a future release.