{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds, TypeOperators, TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE NoStarIsType #-}
{-# OPTIONS_GHC -Wall #-}
module ConCat.Nat where
data Nat = Z | S Nat
type Z = 'Z
type S = 'S
infixl 6 +
type family (a :: Nat) + (b :: Nat) :: Nat where
a + Z = a
a + S b = S (a + b)
infixl 6 -
type family a - b :: Nat where
n - Z = n
S n - S m = n - m
infixl 7 *
type family a * b :: Nat where
a * Z = a
a * S b = a + (a * b)
infixr 8 ^
type family a ^ b :: Nat where
a ^ Z = S Z
a ^ S b = a * (a ^ b)
type N0 = Z
type N1 = S N0
type N2 = S N1
type N3 = S N2
type N4 = S N3
type N5 = S N4
type N6 = S N5
type N7 = S N6
type N8 = S N7
type N9 = S N8
type N10 = S N9
type N11 = S N10
type N12 = S N11
type N13 = S N12
type N14 = S N13
type N15 = S N14
type N16 = S N15
type N17 = S N16
type N18 = S N17
type N19 = S N18
type N20 = S N19
type N21 = S N20
type N22 = S N21
type N23 = S N22
type N24 = S N23
type N25 = S N24
type N26 = S N25
type N27 = S N26
type N28 = S N27
type N29 = S N28
type N30 = S N29
type N31 = S N30
type N32 = S N31