Im trying to make a function with this signature :
'a->'b->('a * 'b ->'b)->'b
I have tried to do a function like this :
fun f x y z = z(x,y);
but its signature is different , it is :
'a->'b->('a * 'b ->'c)->'c
How can i make it fit with the requested? Any tip maybe?
I think the least "artificial" would be something like:
fun f x y g = g (x, g (x, y))
which ensures that g's return-type matches the type of its second parameter by calling g twice, with the result of one call being the second argument to the other.
But a simpler solution, if this isn't "cheating", is to just add an explicit type annotation:
fun f x (y : 'b) g : 'b = g (x, y)