Hello.
I must do following exercise, but i don't know how. Have anybody an idea?
class Enum a where
toEnum :: a Int
fromEnum :: Int a
Is it possible to declare (a,b) as a member of
class Enum, given that both a and b are instances
of Enum?
1 reply to this topic
#1
Posted 08 May 2011 - 01:01 PM
|
|
|
#2
Posted 08 May 2011 - 01:27 PM
class Enum a where toEnum :: a -> Int fromEnum :: Int -> a takeTwoEnums :: Enum b => (a, b) -> IntDon't know what you're trying to do but there you go. I think you're trying to look at this from a far too OOP standpoint, what do you mean by "member"? Type classes have no guaranteed data members, only functions which are guaranteed to work on the passed data values. It's far superior to clumping data together in inefficient and thread-unsafe class objects.
Wow I changed my sig!
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account

Back to top









