I’m taking a course on programming languages and the answer to “when is a function a sub type of another function” is very counter-intuitive to me.
To clarify: suppose that we have the following type relation:
Why is the function
(real->bool) a subtype of
(int->bool)? Shouldn’t it be the other way around?
I would expect the criteria for sub typing functions to be: f1 is a subtype of f2 if f2 can take any argument that f1 can take, and f1 returns only values that f2 returns. There clearly are values that f1 can take, but f2 can’t.