I'm curious as to the intended meaning of
let f g = g . g
Without reading further down, I immediately thought: "composing g onto g must require that the argument and result types (domain and range) of g must be identical".
Then, when I read
I don't know what that means, given that sum is [1] "a function of two arguments" yielding a single value (or, if I want to have my daily dose of curry, sum is [2] "a function of one argument yielding a (function of one argument yielding a single value)".
With either reading, I don't know how to reconcile sum with the expectation on the argument to f.
I think that's what the compiler is saying as well.
Expected type: (a -> a) -> a -> a
Actual type: a -> a -> a
The "expected type" expression seems to match what I expected from the definition of f, and the "actual type" expression seems to match reading [2].
So I'm wondering how that aligns with what you intended to express.
-jn-