[Haskell-cafe] Can sub-classes inheriting instances of parent class?

2009-07-25 Thread Szekeres István
Hi, I'm trying to do something like the following: class Foo a where doit :: (String - IO ()) - a - IO () instance Foo Int where doit f = f . show instance Foo Char where doit f = f . (:[]) So now I have a doit function for Ints and Chars, that takes a function and does the IO

classes and instances

2001-10-04 Thread Russo, Tom
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

Re: classes and instances

2001-10-04 Thread Ashley Yakeley
At 2001-10-04 08:31, Russo, Tom wrote: 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? Oh, 5 isn't necessarily an Int. It's of type Num a = a,