Hi
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
I get an error message that makes absolutely no sense to me:
src/CSVTree.hs:12:9:
Could not deduce (b ~ [Char])
from the context (A b)
bound by the type signature for f :: A b => String -> b
at src/CSVTree.hs:12:3-9
`b' is a rigid type variable bound by
the type signature for f :: A b => String -> b
at src/CSVTree.hs:12:3
In the expression: x
In an equation for `f': f x = x
In the instance declaration for `A String'
make: *** [compile] Error 1
Can someone please explain: how I can achieve my goal; and why my code is failing; simply and in plain English.
Thanks,
Larry
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe