
21 Dec
2009
21 Dec
'09
5:48 a.m.
On Mon, Dec 21, 2009 at 11:28 AM, Daniel Fischer
Am Montag 21 Dezember 2009 10:56:06 schrieb kane96@gmx.de:
Now everything works but to print Z also for negative Integers. Don't know how to implement the <=0 or le0 in this case again:
instance Enum Nat where toEnum 0 = Z toEnum (n+1) = S(toEnum n)
Note that many frown upon (n+k)-patterns and they may be removed from the language in future.
In fact they _have_been_ removed from the standard in Haskell 2010, so in ghc 6.14 they'll become an extension instead of working by default. You just have to use n as a pattern and (n-1) instead of n in the body. -- Jedaï