Starting from a full expression, everything works as expected in the ocaml evaluator.
# fst (fst ((1, 2), 3)) ;;
- : int = 1
Imagine the result of passing functions around but failing to put them in proper context. I'll exemplify in these examples:
# fst fst ;; # expect error
Error: This expression has type 'a * 'b -> 'a
but an expression was expected of type 'c * 'd
# (fst fst) whatever ;;
Error: This expression has type 'a * 'b -> 'a
but an expression was expected of type 'c * 'd
# fst fst whatever ;;
Error: This expression has type 'a * 'b -> 'a
but an expression was expected of type ('c -> 'd) * 'e
The last Error message has what I don't understand. What is it that makes ocaml substitute type ('c -> 'd) * 'e
for 'c * 'd
when analyzing the last expression which has three tokens but no brackets?
Looking at Function application I can only guess (but can't say) that this might have to do with associations and how ocaml looks at a function and arguments juxtaposed. Any hints as to where to look?