[Haskell-beginners] foldr for Nats

kane96 at gmx.de kane96 at gmx.de
Tue Jan 26 05:52:45 EST 2010

I have:
data Nat = Z | S Nat deriving (Eq,Ord,Show)
and should write a function that works for Nats like foldr for list where:
instance Enum Nat where
    toEnum i | i < 0 = error "foo"
                    | i == 0 = Z
                    | otherwise = S (toEnum (i-1))
Can someone give me a hint how to do this?

Nur noch bis 31.01.2010: DSL-Komplettpaket für 16,99 Euro/mtl.!*

More information about the Beginners mailing list