This is questions 3.2.3 (f) from Ullman's Elements book.
The questions is to figure out what the types of b,c,d,e are
for the following function
fun f(a:int,b,c,d,e)=
if b<c then d else e
My answer is that b and c must be of the same type(< operator). Also d
and e must be of the same type since the then and else branches of an if
must have the same type. a is not used but is known to be of type int.
Other than that we cannot further tell which are the types of b,c,d,e.
Now, Running the code in the sml interpreter, however, shows that
b and c are of type int.
val f = fn : int * int * int * 'a * 'a -> 'a
How is it that the int type is inferred for b and c?


|