
11 Nov
2014
11 Nov
'14
5:19 p.m.
On Tue, Nov 11, 2014 at 03:59:50PM -0500, Larry Lee wrote:
I have a very simple problem. I have a class and want to define a function in that class that returns a different instance of the same class.
I tried accomplishing this as follows:
class A a where f :: A b => a -> b
This fails however when I try to instantiate it. For example:
instance A String where f x = x
The `f` that you defined has type `String -> String`. However, given the definition of the class `A` it should have been of type `A b => String -> b`. What exactly are you trying to do here? This is probably not the way to go about it. Tom