Thanks for pointing to "type level integers". With that I have found:

For example:

data Zero = Zero
data Succ a = Succ a

class Card c where
    c2num:: c -> Integer

    cpred::(Succ c) -> c
    cpred = undefined

instance Card Zero where 
    c2num _ = 0

instance (Card c) => Card (Succ c) where
    c2num x = 1 + c2num (cpred x)

main = do

putStrLn $ show $ c2num (Succ (Succ Zero))

I will continue to examine the topic in the following days, according to my 

Thanks a lot,


On Sunday, April 28, 2013 07:58:58 Stephen Tetley wrote:
> What you probably want are type level integers (naturals)
> Yury Sulsky used them in the message above - basically you can't use
> literal numbers 1,2,3,... etc as they are values of type Int (or
> Integer, etc...) instead you have to use type level numbers:
> data One
> data Two
> Work is ongoing for type level numbers in GHC and there are user
> libraries on Hackage so there is a lot of work to crib from.

Haskell-Cafe mailing list

Reply via email to