singleton-nats-0.4.0.4: Unary natural numbers relying on the singletons infrastructure.

Safe HaskellNone
LanguageHaskell2010

Data.Nat

Synopsis

Documentation

data Nat Source #

Constructors

Z 
S Nat 

Instances

Eq Nat Source # 

Methods

(==) :: Nat -> Nat -> Bool #

(/=) :: Nat -> Nat -> Bool #

Ord Nat Source # 

Methods

compare :: Nat -> Nat -> Ordering #

(<) :: Nat -> Nat -> Bool #

(<=) :: Nat -> Nat -> Bool #

(>) :: Nat -> Nat -> Bool #

(>=) :: Nat -> Nat -> Bool #

max :: Nat -> Nat -> Nat #

min :: Nat -> Nat -> Nat #

Show Nat Source # 

Methods

showsPrec :: Int -> Nat -> ShowS #

show :: Nat -> String #

showList :: [Nat] -> ShowS #

PNum Nat Source # 

Associated Types

type (Nat :+ (arg :: Nat)) (arg1 :: Nat) :: a #

type (Nat :- (arg :: Nat)) (arg1 :: Nat) :: a #

type (Nat :* (arg :: Nat)) (arg1 :: Nat) :: a #

type Negate Nat (arg :: Nat) :: a #

type Abs Nat (arg :: Nat) :: a #

type Signum Nat (arg :: Nat) :: a #

type FromInteger Nat (arg :: Nat) :: a #

SNum Nat Source # 
POrd Nat Source # 

Associated Types

type Compare Nat (arg :: Nat) (arg1 :: Nat) :: Ordering #

type (Nat :< (arg :: Nat)) (arg1 :: Nat) :: Bool #

type (Nat :<= (arg :: Nat)) (arg1 :: Nat) :: Bool #

type (Nat :> (arg :: Nat)) (arg1 :: Nat) :: Bool #

type (Nat :>= (arg :: Nat)) (arg1 :: Nat) :: Bool #

type Max Nat (arg :: Nat) (arg1 :: Nat) :: a #

type Min Nat (arg :: Nat) (arg1 :: Nat) :: a #

SOrd Nat => SOrd Nat Source # 

Methods

sCompare :: Sing Nat t1 -> Sing Nat t2 -> Sing Ordering (Apply Nat Ordering (Apply Nat (TyFun Nat Ordering -> Type) (CompareSym0 Nat) t1) t2) #

(%:<) :: Sing Nat t1 -> Sing Nat t2 -> Sing Bool (Apply Nat Bool (Apply Nat (TyFun Nat Bool -> Type) ((:<$) Nat) t1) t2) #

(%:<=) :: Sing Nat t1 -> Sing Nat t2 -> Sing Bool (Apply Nat Bool (Apply Nat (TyFun Nat Bool -> Type) ((:<=$) Nat) t1) t2) #

(%:>) :: Sing Nat t1 -> Sing Nat t2 -> Sing Bool (Apply Nat Bool (Apply Nat (TyFun Nat Bool -> Type) ((:>$) Nat) t1) t2) #

(%:>=) :: Sing Nat t1 -> Sing Nat t2 -> Sing Bool (Apply Nat Bool (Apply Nat (TyFun Nat Bool -> Type) ((:>=$) Nat) t1) t2) #

sMax :: Sing Nat t1 -> Sing Nat t2 -> Sing Nat (Apply Nat Nat (Apply Nat (TyFun Nat Nat -> Type) (MaxSym0 Nat) t1) t2) #

sMin :: Sing Nat t1 -> Sing Nat t2 -> Sing Nat (Apply Nat Nat (Apply Nat (TyFun Nat Nat -> Type) (MinSym0 Nat) t1) t2) #

SEq Nat Source # 

Methods

(%:==) :: Sing Nat a -> Sing Nat b -> Sing Bool ((Nat :== a) b) #

(%:/=) :: Sing Nat a -> Sing Nat b -> Sing Bool ((Nat :/= a) b) #

PEq Nat Source # 

Associated Types

type (Nat :== (x :: Nat)) (y :: Nat) :: Bool #

type (Nat :/= (x :: Nat)) (y :: Nat) :: Bool #

SDecide Nat Source # 

Methods

(%~) :: Sing Nat a -> Sing Nat b -> Decision ((Nat :~: a) b) #

SingKind Nat Source # 

Associated Types

type Demote Nat = (r :: *) #

SingI Nat Z Source # 

Methods

sing :: Sing Z a #

SingI Nat n => SingI Nat (S n) Source # 

Methods

sing :: Sing (S n) a #

Eq (SNat n) Source # 

Methods

(==) :: SNat n -> SNat n -> Bool #

(/=) :: SNat n -> SNat n -> Bool #

Ord (SNat n) Source # 

Methods

compare :: SNat n -> SNat n -> Ordering #

(<) :: SNat n -> SNat n -> Bool #

(<=) :: SNat n -> SNat n -> Bool #

(>) :: SNat n -> SNat n -> Bool #

(>=) :: SNat n -> SNat n -> Bool #

max :: SNat n -> SNat n -> SNat n #

min :: SNat n -> SNat n -> SNat n #

Show (Sing Nat n) Source # 

Methods

showsPrec :: Int -> Sing Nat n -> ShowS #

show :: Sing Nat n -> String #

showList :: [Sing Nat n] -> ShowS #

SuppressUnusedWarnings (TyFun Nat Nat -> *) SSym0 Source # 
data Sing Nat Source # 
data Sing Nat where
type Demote Nat Source # 
type Demote Nat = Nat
type FromInteger Nat a Source # 
type FromInteger Nat a = Lit a
type Signum Nat a Source # 
type Signum Nat a = Error Symbol Nat "Data.Nat: signum not implemented"
type Abs Nat a Source # 
type Abs Nat a = NatAbs a
type Negate Nat arg Source # 
type Negate Nat arg = Apply Nat Nat (Negate_6989586621679400878Sym0 Nat) arg
type (:*) Nat a b Source # 
type (:*) Nat a b = NatMul a b
type (:-) Nat a b Source # 
type (:-) Nat a b = NatMinus a b
type (:+) Nat a b Source # 
type (:+) Nat a b = NatPlus a b
type Min Nat arg arg1 Source # 
type Min Nat arg arg1 = Apply Nat Nat (Apply Nat (TyFun Nat Nat -> Type) (Min_6989586621679304448Sym0 Nat) arg) arg1
type Max Nat arg arg1 Source # 
type Max Nat arg arg1 = Apply Nat Nat (Apply Nat (TyFun Nat Nat -> Type) (Max_6989586621679304415Sym0 Nat) arg) arg1
type (:>=) Nat arg arg1 Source # 
type (:>=) Nat arg arg1 = Apply Nat Bool (Apply Nat (TyFun Nat Bool -> Type) (TFHelper_6989586621679304382Sym0 Nat) arg) arg1
type (:>) Nat arg arg1 Source # 
type (:>) Nat arg arg1 = Apply Nat Bool (Apply Nat (TyFun Nat Bool -> Type) (TFHelper_6989586621679304349Sym0 Nat) arg) arg1
type (:<=) Nat arg arg1 Source # 
type (:<=) Nat arg arg1 = Apply Nat Bool (Apply Nat (TyFun Nat Bool -> Type) (TFHelper_6989586621679304316Sym0 Nat) arg) arg1
type (:<) Nat arg arg1 Source # 
type (:<) Nat arg arg1 = Apply Nat Bool (Apply Nat (TyFun Nat Bool -> Type) (TFHelper_6989586621679304283Sym0 Nat) arg) arg1
type Compare Nat a1 a2 Source # 
type Compare Nat a1 a2
type (:/=) Nat x y Source # 
type (:/=) Nat x y = Not ((:==) Nat x y)
type (:==) Nat a b Source # 
type (:==) Nat a b
type Apply Nat Nat SSym0 l Source # 
type Apply Nat Nat SSym0 l = S l

type family NatPlus (a :: Nat) (a :: Nat) :: Nat where ... Source #

Equations

NatPlus Z b = b 
NatPlus (S a) b = Apply SSym0 (Apply (Apply NatPlusSym0 a) b) 

type family NatMul (a :: Nat) (a :: Nat) :: Nat where ... Source #

Equations

NatMul Z b = ZSym0 
NatMul (S a) b = Apply (Apply NatPlusSym0 b) (Apply (Apply NatMulSym0 a) b) 

type family NatMinus (a :: Nat) (a :: Nat) :: Nat where ... Source #

Equations

NatMinus Z b = ZSym0 
NatMinus (S a) (S b) = Apply (Apply NatMinusSym0 a) b 
NatMinus a Z = a 

type family NatAbs (a :: Nat) :: Nat where ... Source #

Equations

NatAbs n = n 

type SNat = (Sing :: Nat -> Type) Source #

data family Sing k (a :: k) :: * #

The singleton kind-indexed data family.

Instances

Eq (SNat n) # 

Methods

(==) :: SNat n -> SNat n -> Bool #

(/=) :: SNat n -> SNat n -> Bool #

Ord (SNat n) # 

Methods

compare :: SNat n -> SNat n -> Ordering #

(<) :: SNat n -> SNat n -> Bool #

(<=) :: SNat n -> SNat n -> Bool #

(>) :: SNat n -> SNat n -> Bool #

(>=) :: SNat n -> SNat n -> Bool #

max :: SNat n -> SNat n -> SNat n #

min :: SNat n -> SNat n -> SNat n #

Show (Sing Nat n) # 

Methods

showsPrec :: Int -> Sing Nat n -> ShowS #

show :: Sing Nat n -> String #

showList :: [Sing Nat n] -> ShowS #

data Sing Bool 
data Sing Bool where
data Sing Ordering 
data Sing Nat 
data Sing Nat where
data Sing Symbol 
data Sing Symbol where
data Sing () 
data Sing () where
data Sing Nat # 
data Sing Nat where
data Sing [a] 
data Sing [a] where
data Sing (Maybe a) 
data Sing (Maybe a) where
data Sing (NonEmpty a) 
data Sing (NonEmpty a) where
data Sing (Either a b) 
data Sing (Either a b) where
data Sing (a, b) 
data Sing (a, b) where
data Sing ((~>) k1 k2) 
data Sing ((~>) k1 k2) = SLambda {}
data Sing (a, b, c) 
data Sing (a, b, c) where
data Sing (a, b, c, d) 
data Sing (a, b, c, d) where
data Sing (a, b, c, d, e) 
data Sing (a, b, c, d, e) where
data Sing (a, b, c, d, e, f) 
data Sing (a, b, c, d, e, f) where
data Sing (a, b, c, d, e, f, g) 
data Sing (a, b, c, d, e, f, g) where

class PNum a #

Instances

PNum Nat 

Associated Types

type (Nat :+ (arg :: Nat)) (arg1 :: Nat) :: a #

type (Nat :- (arg :: Nat)) (arg1 :: Nat) :: a #

type (Nat :* (arg :: Nat)) (arg1 :: Nat) :: a #

type Negate Nat (arg :: Nat) :: a #

type Abs Nat (arg :: Nat) :: a #

type Signum Nat (arg :: Nat) :: a #

type FromInteger Nat (arg :: Nat) :: a #

PNum Nat # 

Associated Types

type (Nat :+ (arg :: Nat)) (arg1 :: Nat) :: a #

type (Nat :- (arg :: Nat)) (arg1 :: Nat) :: a #

type (Nat :* (arg :: Nat)) (arg1 :: Nat) :: a #

type Negate Nat (arg :: Nat) :: a #

type Abs Nat (arg :: Nat) :: a #

type Signum Nat (arg :: Nat) :: a #

type FromInteger Nat (arg :: Nat) :: a #

class SNum a #

Minimal complete definition

(%:+), (%:*), sAbs, sSignum, sFromInteger

data SSym0 (l :: TyFun Nat Nat) Source #

Constructors

SameKind (Apply SSym0 arg) (SSym1 arg) => SSym0KindInference 

type SSym1 (t :: Nat) = S t Source #

type ZSym0 = Z Source #

type family Lit n where ... Source #

Provides a shorthand for Nat-s using GHC.TypeLits, for example:

>>> :kind! Lit 3
Lit 3 :: Nat
= 'S ('S ('S 'Z))

Equations

Lit 0 = Z 
Lit n = S (Lit (n - 1)) 

type SLit n = Sing (Lit n) Source #

sLit :: forall (n :: Nat). SingI (Lit n) => Sing (Lit n) Source #

Shorthand for SNat literals using TypeApplications.

>>> :set -XTypeApplications
>>> sLit @5
SS (SS (SS (SS (SS SZ))))