Copyright | (C) 2013 Richard Eisenberg |
---|---|
License | BSD-style (see LICENSE) |
Maintainer | Richard Eisenberg (rae@cs.brynmawr.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, rae
at cs.brynmawr.edu
)
know.
Synopsis
- data Z
- type family Sing :: k -> Type
- data SZ :: Z -> Type where
- type ZeroSym0 = Zero :: Z
- data SSym0 a6989586621679063792
- type SSym1 (a6989586621679063792 :: Z) = S a6989586621679063792 :: Z
- data PSym0 a6989586621679063794
- type PSym1 (a6989586621679063794 :: Z) = P a6989586621679063794 :: Z
- zToInt :: Z -> Int
- szToInt :: Sing (z :: Z) -> Int
- type family Succ (z :: Z) :: Z where ...
- type family Pred (z :: Z) :: Z where ...
- type family Negate (z :: Z) :: Z where ...
- type family (a :: Z) #+ (b :: Z) :: Z where ...
- type family (a :: Z) #- (b :: Z) :: Z where ...
- type family (a :: Z) #* (b :: Z) :: Z where ...
- type family (a :: Z) #/ (b :: Z) :: Z where ...
- sSucc :: Sing z -> Sing (Succ z)
- sPred :: Sing z -> Sing (Pred z)
- sNegate :: Sing z -> Sing (Negate z)
- type family (a :: Z) < (b :: Z) :: Bool where ...
- type family NonNegative z :: Constraint where ...
- 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 :: SZ 'Zero
- sOne :: SZ ('S 'Zero)
- sTwo :: SZ ('S ('S 'Zero))
- sThree :: SZ ('S ('S ('S 'Zero)))
- sFour :: SZ ('S ('S ('S ('S 'Zero))))
- sFive :: SZ ('S ('S ('S ('S ('S 'Zero)))))
- sMOne :: SZ ('P 'Zero)
- sMTwo :: SZ ('P ('P 'Zero))
- sMThree :: SZ ('P ('P ('P 'Zero)))
- sMFour :: SZ ('P ('P ('P ('P 'Zero))))
- sMFive :: SZ ('P ('P ('P ('P ('P 'Zero)))))
- pZero :: SZ 'Zero
- pOne :: SZ ('S 'Zero)
- pTwo :: SZ ('S ('S 'Zero))
- pThree :: SZ ('S ('S ('S 'Zero)))
- pFour :: SZ ('S ('S ('S ('S 'Zero))))
- pFive :: SZ ('S ('S ('S ('S ('S 'Zero)))))
- pMOne :: SZ ('P 'Zero)
- pMTwo :: SZ ('P ('P 'Zero))
- pMThree :: SZ ('P ('P ('P 'Zero)))
- pMFour :: SZ ('P ('P ('P ('P 'Zero))))
- pMFive :: SZ ('P ('P ('P ('P ('P 'Zero)))))
- pSucc :: forall (z :: Z). SZ z -> SZ (Succ z)
- pPred :: forall (z :: Z). SZ z -> SZ (Pred z)
The Z
datatype
The datatype for type-level integers.
Instances
type family Sing :: k -> Type #
The singleton kind-indexed type family.
Instances
data SZ :: Z -> Type where Source #
SZero :: SZ (Zero :: Z) | |
SS :: forall (n :: Z). (Sing n) -> SZ (S n :: Z) | |
SP :: forall (n :: Z). (Sing n) -> SZ (P n :: Z) |
Instances
SDecide Z => TestCoercion SZ Source # | |
Defined in Data.Metrology.Z | |
SDecide Z => TestEquality SZ Source # | |
Defined in Data.Metrology.Z |
Defunctionalization symbols (these can be ignored)
data SSym0 a6989586621679063792 Source #
Instances
SuppressUnusedWarnings SSym0 Source # | |
Defined in Data.Metrology.Z suppressUnusedWarnings :: () # | |
SingI SSym0 Source # | |
Defined in Data.Metrology.Z | |
type Apply SSym0 (a6989586621679063792 :: Z) Source # | |
Defined in Data.Metrology.Z |
data PSym0 a6989586621679063794 Source #
Instances
SuppressUnusedWarnings PSym0 Source # | |
Defined in Data.Metrology.Z suppressUnusedWarnings :: () # | |
SingI PSym0 Source # | |
Defined in Data.Metrology.Z | |
type Apply PSym0 (a6989586621679063794 :: Z) Source # | |
Defined in Data.Metrology.Z |
Conversions
Type-level operations
Arithmetic
Comparisons
type family NonNegative z :: Constraint where ... 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 :: SZ ('S 'Zero) Source #
Deprecated: The singleton prefix is changing from p
to s
. The p
versions will be removed in a future release.
pTwo :: SZ ('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 :: SZ ('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 :: SZ ('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 :: SZ ('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 :: SZ ('P 'Zero) Source #
Deprecated: The singleton prefix is changing from p
to s
. The p
versions will be removed in a future release.
pMTwo :: SZ ('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 :: SZ ('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 :: SZ ('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 :: SZ ('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.