
4 Oct
2001
4 Oct
'01
11:31 a.m.
Hello, I'm learning haskell and I'm having some trouble with type classes. I understand them conceptually, but when I try to create an instance I run into problems. As a simple example, I create a class called ToInt:
class ToCh a where int :: a -> Int
Then I create an instance:
instance ToInt Int where: int n = n
However, when I try to use the function int :: Int -> Int at the hugs prompt, I get the following error message: Main> int 5 ERROR - Unresolved overloading *** Type : (Num a, ToInt a) => Int *** Expression : int 5 Can someone explain what the problem is, and how to interpret the error message I'm getting? thanks _t
8636
Age (days ago)
8636
Last active (days ago)
0 comments
1 participants
participants (1)
-
Russo, Tom