{-# LANGUAGE ScopedTypeVariables #-} -- .$Header: c:/Source/Haskell/Type/Data/Type/RCS/Nat.hs,v 1.1 2011/03/05 00:32:26 dosuser Exp dosuser $ module Data.Type.Nat where data Z = Z data S n = S n zero :: Z zero = Z one :: S Z one = S Z two :: S (S Z) two = S one three :: S (S (S Z)) three = S two class Nat n where fromNat :: Enum e => n -> e instance Nat Z where fromNat _ = toEnum 0 instance forall n. Nat n => Nat (S n) where fromNat _ = succ $ fromNat (undefined :: n) -- vim: expandtab:tabstop=4:shiftwidth=4