I'm trying to create a function that returns itself in a tuple of values. Basically the idea is that the caller would get back transformed values, along with a new (curried) version of the function to use further along in the processing.
However, at the moment, I'm stuck trying to come up with a no-op (i.e. do-nothing) version of this function. So the following snippet is obviously fine - this is a no-op which doesn't return itself:
noOp s as xs = (s, as, xs)
But if I change to this:
noOp s as xs = (s, as, xs, noOp)
I get the "infinite type" error:
Occurs check: cannot construct the infinite type:
t3 = t0 -> t1 -> t2 -> (t0, t1, t2, t3)
In the expression: noop
In the expression: (s, as, xs, noop)
In an equation for `noop': noop s as xs = (s, as, xs, noop)
There's plenty of discussion on SO about handling the infinite type error - but I can't quite figure out how to apply to my problem.
Any advice welcomed...