@@ -15,6 +15,15 @@ data N = Z | S N
1515 deriving ( Eq, Ord, Read, Show
1616 , Generic, Typeable )
1717
18+class KnownPeano (p :: N) where
19+ peanoVal :: proxy p -> Integer
20+
21+instance KnownPeano Z where
22+ peanoVal _ = 0
23+
24+instance (KnownPeano n) => KnownPeano (S n) where
25+ peanoVal _ = succ $ peanoVal (Proxy :: Proxy n)
26+
1827type family ToNat (a :: N) :: Nat where
1928 ToNat Z = 0
2029 ToNat (S a) = 1 + (ToNat a)