Hello I am getting ready for my finals and there is always ml type inference on the exams . i.e. we are asked to write the type of a function like this one :
fun ugh x y z = x z (y z);
val ugh = fn : ('a -> 'b -> 'c) -> ('a -> 'b) -> 'a -> 'c
or
fun doh x y z = z (x y ) (y + 1);
val doh = fn : (int -> 'a) -> int -> ('a -> int -> 'b) -> 'b
However all the ways I am trying to infer the type I always get it wrong . Although there are examples online there are no examples for functions like that . Is there a way to make up the type following some guidelines ? The guidelines would be best if applied to the first example .