
21 Dec
2009
21 Dec
'09
5:25 a.m.
2009/12/21
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) fromEnum Z = 0 fromEnum (S n) = 1 + fromEnum n
Again, look into guards. You are definitely on the right track. Again, you should look into guards. instance Enum Nat where toEnum n | n <= 0 = Z | otherwise = ... -- do what with n? fromEnum Z = 0 fromEnum (S n) = 1 + fromEnum n You are on the right track. -- Deniz Dogan