[Haskell-beginners] Enum for natural numbers

kane96 at gmx.de kane96 at gmx.de
Thu Dec 17 12:21:21 EST 2009


Hi,
I have data Nat = Z | S Nat deriving (Eq,Ord,Show)

toEnum should return Z for negative numbers. I did something like this but the problem is I don't know how to set "less than". I tried > and lt:

instance Enum Nat where
    toEnum (gt 0) = S Z
    toEnum (lt 1) = Z
-- 
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01


More information about the Beginners mailing list