{-# LANGUAGE ScopedTypeVariables #-}
-- .$Header$
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