-----------------------------------------------------------------------------
-- |
-- Module      :  Data.Type.Natural
  Copyright    :   ( c )   2017
-- License     :  BSD3 (see the file LICENSE)
--
  Maintainer   :   zocca marco gmail
-- Stability   :  experimental
-- Portability :  portable
--
  Type - level naturals inspired by   -natural but available in similar form in many other  packages
--
-----------------------------------------------------------------------------
module Data.Type.Natural where



  data Zero = Zero deriving ( Eq , Show )
  data Succ a = Succ a deriving ( Eq , Show )
-- type D1 = Succ Zero
  type D2 = Succ D1
-- type D3 = Succ D2 

  class  a where
--   fromNat :: a -> Int
--   toNat :: Int -> a
  instance   where
--   fromNat _ = 0
    toNat _ = Zero
  instance  a = > Nat ( Succ a ) where
--   fromNat _ = 1 + fromNat (undefined :: a)
--   toNat n = Succ (toNat (n - 1))

data Nat a = Zero | Succ (Nat a) deriving (Eq, Show)
fromNat :: Num t => Nat t1 -> t
fromNat Zero = 0
fromNat (Succ n) = 1 + fromNat n

toNat 0 = Zero
toNat n = Succ (toNat (n - 1))
  instance  (  a ) where
--   m + n = fromNat m + fromNat n

---------------------------------------------------------------------------
 |
 Module      :  Data.Type.Natural
 License     :  BSD3 (see the file LICENSE)

 Stability   :  experimental
 Portability :  portable


---------------------------------------------------------------------------
 type D1 = Succ Zero
 type D3 = Succ D2 
   fromNat :: a -> Int
   toNat :: Int -> a
   fromNat _ = 0
   fromNat _ = 1 + fromNat (undefined :: a)
   toNat n = Succ (toNat (n - 1))
   m + n = fromNat m + fromNat n
  Copyright    :   ( c )   2017
  Maintainer   :   zocca marco gmail
  Type - level naturals inspired by   -natural but available in similar form in many other  packages
module Data.Type.Natural where



  data Zero = Zero deriving ( Eq , Show )
  data Succ a = Succ a deriving ( Eq , Show )
  type D2 = Succ D1

  class  a where
  instance   where
    toNat _ = Zero
  instance  a = > Nat ( Succ a ) where

data Nat a = Zero | Succ (Nat a) deriving (Eq, Show)
fromNat :: Num t => Nat t1 -> t
fromNat Zero = 0
fromNat (Succ n) = 1 + fromNat n

toNat 0 = Zero
toNat n = Succ (toNat (n - 1))
  instance  (  a ) where
