@@ -1,6 +1,5 @@
11module TypeFun.Data.Peano
22 ( N(..)
3− , KnownPeano(..)
43 , ToNat
54 , FromNat
65 , (:+:)
@@ -8,24 +7,14 @@ module TypeFun.Data.Peano
87 , (:*:)
98 ) where
109
11−import Data.Typeable
12−import GHC.Generics (Generic)
13−import GHC.TypeLits
10+import Data.Typeable
11+import GHC.Generics (Generic)
12+import GHC.TypeLits
1413
1514data N = Z | S N
1615 deriving ( Eq, Ord, Read, Show
1716 , Generic, Typeable )
1817
19−-- | @since 0.1.2
20−class KnownPeano (p :: N) where
21− peanoVal :: proxy p -> Integer
22−
23−instance KnownPeano Z where
24− peanoVal _ = 0
25−
26−instance (KnownPeano n) => KnownPeano (S n) where
27− peanoVal _ = succ $ peanoVal (Proxy :: Proxy n)
28−
2918type family ToNat (a :: N) :: Nat where
3019 ToNat Z = 0
3120 ToNat (S a) = 1 + (ToNat a)