I have a function which contains an abstract data type as a parameter. In order for me to be able to equate this abstract data type I used:
myfunction:: Eq x=> [x]->[x]->[x]
So it takes in two lists of x, and outputs a list of [x]
However, when I call it from another function:
anotherfunction::[x] -> [x] -> [x]
anotherfunction a b = myfunction a b
it says
No instance for (Eq x) arising from a use of myfunction, in the
expression myfunction a b
However, if I call myfunction from the console, with the two arguments it works fine.
How do I solve this?
Use
Eqin the type ofanotherfunction.myfunctionworks only with types that are in theEqclass. But your current definition ofanotherfunctionclaims it can work with any type. This would cause a problem if you calledanotherfunctionwith a type that is not in theEqclass – it wouldn’t be able to callmyfunction.