I'm new to Haskell and i have the following problem. I have the function foo that has to apply a function (given by parameter) until there are no more changes. That's the signature of the function
foo :: (a-> a )-> a-> a
I tried this
foo f x = if ((f x) == x) then x else foo (f (f x))
I get this
No instance for (Eq a) arising from a use of `=='
I know why i get it (a is generic so the compiler doesn't know if derives Eq) but don't know how to solve. I was thinking a way to divide the function in two cases (when the input derives Eq and when it doesn't) but I didn't find a way to do it. All the solutions that i found to this problem changed the signature of the function to Eq a but i am not allowed to change the signature.
PS: I don't care what does the function when the parameter doesn't derive Eq because i wont use it in this case.
Edit: I did the corrections that willen said