[Haskell-beginners] Enum for natural numbers
Deniz Dogan
deniz.a.m.dogan at gmail.com
Fri Dec 18 12:06:32 EST 2009
2009/12/17 <kane96 at gmx.de>:
> 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
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
Fill in the gaps:
instance Enum Nat where
toEnum x | x <= 0 = ...
| otherwise = ...
--
Deniz Dogan
More information about the Beginners
mailing list