type-combinators-0.2.4.3: A collection of data types for type-level programming

CopyrightCopyright (C) 2015 Kyle Carter
LicenseBSD3
MaintainerKyle Carter <kylcarte@indiana.edu>
Stabilityexperimental
PortabilityRankNTypes
Safe HaskellNone
LanguageHaskell2010

Type.Family.Nat

Description

Type-level natural numbers, along with frequently used type families over them.

Synopsis

Documentation

data N Source #

Constructors

Z 
S N 

Instances

Eq N Source # 

Methods

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

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

Ord N Source # 

Methods

compare :: N -> N -> Ordering #

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

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

(>) :: N -> N -> Bool #

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

max :: N -> N -> N #

min :: N -> N -> N #

Show N Source # 

Methods

showsPrec :: Int -> N -> ShowS #

show :: N -> String #

showList :: [N] -> ShowS #

TestEquality N Nat # 

Methods

testEquality :: f a -> f b -> Maybe ((Nat :~: a) b) #

Read1 N Nat Source # 

Methods

readsPrec1 :: Int -> ReadS (Some Nat f) Source #

Read1 N Fin Source # 

Methods

readsPrec1 :: Int -> ReadS (Some Fin f) Source #

Show1 N Nat Source # 

Methods

showsPrec1 :: Int -> f a -> ShowS Source #

show1 :: f a -> String Source #

Show1 N Fin Source # 

Methods

showsPrec1 :: Int -> f a -> ShowS Source #

show1 :: f a -> String Source #

Ord1 N Nat Source # 

Methods

compare1 :: f a -> f a -> Ordering Source #

(<#) :: f a -> f a -> Bool Source #

(>#) :: f a -> f a -> Bool Source #

(<=#) :: f a -> f a -> Bool Source #

(>=#) :: f a -> f a -> Bool Source #

Ord1 N Fin Source # 

Methods

compare1 :: f a -> f a -> Ordering Source #

(<#) :: f a -> f a -> Bool Source #

(>#) :: f a -> f a -> Bool Source #

(<=#) :: f a -> f a -> Bool Source #

(>=#) :: f a -> f a -> Bool Source #

Eq1 N Nat Source # 

Methods

eq1 :: f a -> f a -> Bool Source #

neq1 :: f a -> f a -> Bool Source #

Eq1 N Fin Source # 

Methods

eq1 :: f a -> f a -> Bool Source #

neq1 :: f a -> f a -> Bool Source #

BoolEquality N Nat Source # 

Methods

boolEquality :: f a -> f b -> Boolean ((Nat == a) b) Source #

Known N Nat Z Source #

Z_ is the canonical construction of a Nat Z.

Associated Types

type KnownC Nat (Z :: Nat -> *) (a :: Nat) :: Constraint Source #

Methods

known :: Z a Source #

Read2 N N IFin Source # 

Methods

readsPrec2 :: Int -> ReadS (Some2 IFin k f) Source #

Show2 N N IFin Source # 

Methods

showsPrec2 :: Int -> f a b -> ShowS Source #

show2 :: f a b -> String Source #

Ord2 N N IFin Source # 

Methods

compare2 :: f a b -> f a b -> Ordering Source #

(<##) :: f a b -> f a b -> Bool Source #

(>##) :: f a b -> f a b -> Bool Source #

(<=##) :: f a b -> f a b -> Bool Source #

(>=##) :: f a b -> f a b -> Bool Source #

Eq2 N N IFin Source # 

Methods

eq2 :: f a b -> f a b -> Bool Source #

neq2 :: f a b -> f a b -> Bool Source #

Known N Nat n => Known N Nat (S n) Source #

If n is a canonical construction of Nat n, S_ n is the canonical construction of Nat (S n).

Associated Types

type KnownC Nat (S n :: Nat -> *) (a :: Nat) :: Constraint Source #

Methods

known :: S n a Source #

Show1 N (IFin x) Source # 

Methods

showsPrec1 :: Int -> f a -> ShowS Source #

show1 :: f a -> String Source #

Ord1 N (IFin x) Source # 

Methods

compare1 :: f a -> f a -> Ordering Source #

(<#) :: f a -> f a -> Bool Source #

(>#) :: f a -> f a -> Bool Source #

(<=#) :: f a -> f a -> Bool Source #

(>=#) :: f a -> f a -> Bool Source #

Eq1 N (IFin x) Source # 

Methods

eq1 :: f a -> f a -> Bool Source #

neq1 :: f a -> f a -> Bool Source #

(~) N n (Len k as) => Witness ØC (Known N Nat n, Known [k] (Length k) as) (Length k as) Source # 

Associated Types

type WitnessC (ØC :: Constraint) ((Known N Nat n, Known [k] (Length k) as) :: Constraint) (Length k as) :: Constraint Source #

Methods

(\\) :: ØC => ((Known N Nat n, Known [k] (Length k) as) -> r) -> Length k as -> r Source #

(~) N n' (Pred n) => Witness ØC ((~) N (S n') n) (Fin n) Source #

A Fin n is a Witness that n >= 1.

That is, Pred n is well defined.

Associated Types

type WitnessC (ØC :: Constraint) ((~) N (S n') n :: Constraint) (Fin n) :: Constraint Source #

Methods

(\\) :: ØC => ((N ~ S n') n -> r) -> Fin n -> r Source #

Witness ØC (Known N Nat n) (Nat n) Source #

A Nat n is a Witness that there is a canonical construction for Nat n.

Associated Types

type WitnessC (ØC :: Constraint) (Known N Nat n :: Constraint) (Nat n) :: Constraint Source #

Methods

(\\) :: ØC => (Known N Nat n -> r) -> Nat n -> r Source #

(~) N x' (Pred x) => Witness ØC ((~) N (S x') x) (IFin x y) Source #

An IFin x y is a Witness that x >= 1.

That is, Pred x is well defined.

Associated Types

type WitnessC (ØC :: Constraint) ((~) N (S x') x :: Constraint) (IFin x y) :: Constraint Source #

Methods

(\\) :: ØC => ((N ~ S x') x -> r) -> IFin x y -> r Source #

Witness ØC (Known N Nat n) (VecT k n f a) Source # 

Associated Types

type WitnessC (ØC :: Constraint) (Known N Nat n :: Constraint) (VecT k n f a) :: Constraint Source #

Methods

(\\) :: ØC => (Known N Nat n -> r) -> VecT k n f a -> r Source #

((~) Bool lt ((<) x y), (~) Bool eq ((==) N x y), (~) Bool gt ((>) x y), (~) N x' (Pred x)) => Witness ØC ((~) N x (S x'), Known N Nat y, (~) Bool lt False, (~) Bool eq False, (~) Bool gt True) (NatGT x y) Source # 

Associated Types

type WitnessC (ØC :: Constraint) (((~) N x (S x'), Known N Nat y, (~) Bool lt False, (~) Bool eq False, (~) Bool gt True) :: Constraint) (NatGT x y) :: Constraint Source #

Methods

(\\) :: ØC => (((N ~ x) (S x'), Known N Nat y, (Bool ~ lt) False, (Bool ~ eq) False, (Bool ~ gt) True) -> r) -> NatGT x y -> r Source #

((~) Bool lt ((<) x y), (~) Bool eq ((==) N x y), (~) Bool gt ((>) x y)) => Witness ØC ((~) N x y, Known N Nat x, (~) Bool lt False, (~) Bool eq True, (~) Bool gt False) (NatEQ x y) Source # 

Associated Types

type WitnessC (ØC :: Constraint) (((~) N x y, Known N Nat x, (~) Bool lt False, (~) Bool eq True, (~) Bool gt False) :: Constraint) (NatEQ x y) :: Constraint Source #

Methods

(\\) :: ØC => (((N ~ x) y, Known N Nat x, (Bool ~ lt) False, (Bool ~ eq) True, (Bool ~ gt) False) -> r) -> NatEQ x y -> r Source #

((~) Bool lt ((<) x y), (~) Bool eq ((==) N x y), (~) Bool gt ((>) x y), (~) N y' (Pred y)) => Witness ØC ((~) N y (S y'), Known N Nat x, (~) Bool lt True, (~) Bool eq False, (~) Bool gt False) (NatLT x y) Source # 

Associated Types

type WitnessC (ØC :: Constraint) (((~) N y (S y'), Known N Nat x, (~) Bool lt True, (~) Bool eq False, (~) Bool gt False) :: Constraint) (NatLT x y) :: Constraint Source #

Methods

(\\) :: ØC => (((N ~ y) (S y'), Known N Nat x, (Bool ~ lt) True, (Bool ~ eq) False, (Bool ~ gt) False) -> r) -> NatLT x y -> r Source #

type (==) N x y Source # 
type (==) N x y = NatEq x y
type KnownC N Nat Z Source # 
type KnownC N Nat Z = ØC
type KnownC N Nat (S n) Source # 
type KnownC N Nat (S n) = Known N Nat n
type WitnessC ØC (Known N Nat n, Known [k] (Length k) as) (Length k as) Source # 
type WitnessC ØC (Known N Nat n, Known [k] (Length k) as) (Length k as) = (~) N n (Len k as)
type WitnessC ØC ((~) N (S n') n) (Fin n) Source # 
type WitnessC ØC ((~) N (S n') n) (Fin n) = (~) N n' (Pred n)
type WitnessC ØC (Known N Nat n) (Nat n) Source # 
type WitnessC ØC (Known N Nat n) (Nat n) = ØC
type WitnessC ØC ((~) N (S x') x) (IFin x y) Source # 
type WitnessC ØC ((~) N (S x') x) (IFin x y) = (~) N x' (Pred x)
type WitnessC ØC (Known N Nat n) (VecT k n f a) Source # 
type WitnessC ØC (Known N Nat n) (VecT k n f a) = ØC
type WitnessC ØC ((~) N x (S x'), Known N Nat y, (~) Bool lt False, (~) Bool eq False, (~) Bool gt True) (NatGT x y) Source # 
type WitnessC ØC ((~) N x (S x'), Known N Nat y, (~) Bool lt False, (~) Bool eq False, (~) Bool gt True) (NatGT x y) = ((~) Bool lt ((<) x y), (~) Bool eq ((==) N x y), (~) Bool gt ((>) x y), (~) N x' (Pred x))
type WitnessC ØC ((~) N x y, Known N Nat x, (~) Bool lt False, (~) Bool eq True, (~) Bool gt False) (NatEQ x y) Source # 
type WitnessC ØC ((~) N x y, Known N Nat x, (~) Bool lt False, (~) Bool eq True, (~) Bool gt False) (NatEQ x y) = ((~) Bool lt ((<) x y), (~) Bool eq ((==) N x y), (~) Bool gt ((>) x y))
type WitnessC ØC ((~) N y (S y'), Known N Nat x, (~) Bool lt True, (~) Bool eq False, (~) Bool gt False) (NatLT x y) Source # 
type WitnessC ØC ((~) N y (S y'), Known N Nat x, (~) Bool lt True, (~) Bool eq False, (~) Bool gt False) (NatLT x y) = ((~) Bool lt ((<) x y), (~) Bool eq ((==) N x y), (~) Bool gt ((>) x y), (~) N y' (Pred y))

type family IsZero (x :: N) :: Bool where ... Source #

Equations

IsZero Z = True 
IsZero (S x) = False 

zeroCong :: (x ~ y) :- (IsZero x ~ IsZero y) Source #

zNotS :: (Z ~ S x) :- Fail Source #

type family NatEq (x :: N) (y :: N) :: Bool where ... Source #

Equations

NatEq Z Z = True 
NatEq Z (S y) = False 
NatEq (S x) Z = False 
NatEq (S x) (S y) = NatEq x y 

type family Iota (x :: N) = (xs :: [N]) | xs -> x where ... Source #

Equations

Iota Z = Ø 
Iota (S x) = x :< Iota x 

iotaCong :: (x ~ y) :- (Iota x ~ Iota y) Source #

type family Pred (x :: N) :: N where ... Source #

Equations

Pred (S n) = n 

type Pos n = n ~ S (Pred n) Source #

predCong :: (x ~ y) :- (Pred x ~ Pred y) Source #

type family (x :: N) + (y :: N) :: N where ... infixr 6 Source #

Equations

Z + y = y 
(S x) + y = S (x + y) 

data AddW f :: N -> * where Source #

Constructors

AddW :: !(f x) -> !(f y) -> AddW f (x + y) 

addCong :: (w ~ y, x ~ z) :- ((w + x) ~ (y + z)) Source #

type family (x :: N) * (y :: N) :: N where ... infixr 7 Source #

Equations

Z * y = Z 
(S x) * y = (x * y) + y 

data MulW f :: N -> * where Source #

Constructors

MulW :: !(f x) -> !(f y) -> MulW f (x * y) 

mulCong :: (w ~ y, x ~ z) :- ((w * x) ~ (y * z)) Source #

type family (x :: N) ^ (y :: N) :: N where ... infixl 8 Source #

Equations

x ^ Z = S Z 
x ^ (S y) = (x ^ y) * x 

expCong :: (w ~ y, x ~ z) :- ((w ^ x) ~ (y ^ z)) Source #

type family Len (as :: [k]) :: N where ... Source #

Equations

Len Ø = Z 
Len (a :< as) = S (Len as) 

lenCong :: (as ~ bs) :- (Len as ~ Len bs) Source #

type family Ix (x :: N) (as :: [k]) :: k where ... Source #

Equations

Ix Z (a :< as) = a 
Ix (S x) (a :< as) = Ix x as 

ixCong :: (x ~ y, as ~ bs) :- (Ix x as ~ Ix y bs) Source #

type family (x :: N) < (y :: N) :: Bool where ... infix 4 Source #

Equations

Z < Z = False 
Z < (S y) = True 
(S x) < Z = False 
(S x) < (S y) = x < y 

type (<=) x y = (x == y) || (x < y) infix 4 Source #

type family (x :: N) > (y :: N) :: Bool where ... infix 4 Source #

Equations

Z > Z = False 
Z > (S y) = False 
(S x) > Z = True 
(S x) > (S y) = x > y 

type (>=) x y = (x == y) || (x > y) infix 4 Source #

type N0 = Z Source #

Convenient aliases for low-value Peano numbers.

type N1 = S N0 Source #

type N2 = S N1 Source #

type N3 = S N2 Source #

type N4 = S N3 Source #

type N5 = S N4 Source #

type N6 = S N5 Source #

type N7 = S N6 Source #

type N8 = S N7 Source #

type N9 = S N8 Source #

type N10 = S N9 Source #