While trying to define a Haskell function which corresponds to repeated evaluation, I ran into an "Equations give different arities" error. This is my code:
nEvals :: Int -> (a -> a) -> a -> a
nEvals 1 = ($) --equivalent to nEvals 1 f x = f x
nEvals k f = (nEvals (k - 1) f) . f --equivalent to nEvals k f x = nEvals (k - 1) f (f x)
I don't quite understand why Haskell is giving this error, since I'm using pattern matching, not explicitly assigning a value for a given set of inputs. Perhaps Haskell only allows pattern matching on a fixed number of parameters? If so, could someone explain why that decision was made?