[   ^ to index...   |   <-- previous   |   next -->   ]

Type Inference Exercises

Determine whether the following functions/expressions are well-typed or not. If they are well-typed, determine the types of all bound identifiers.

fun trivial(x,y,z) = 1.0;



fun mouse(shrew) = shrew::nil;



fun easy(simple, complex) = simple orelse complex > 0;




fun trout(salmon, pike, mackerel, sole) =
    let
        val snapper = (salmon, 4);
        val eel = if hd(pike) then [mackerel, tl(pike)]
                  else [];
    in
        {scales = "a " ^ #1(snapper),
         tail = (eel, sole)}
    end;






























Keunwoo Lee
Last modified: Wed Apr 4 21:11:46 PDT 2001