Alexander Bernauer a écrit :
Why is it that the first example does not compile while the later ones do?
Because type constraints are considered: - only for type restriction, not for generalization; - after the type inference algorithm is executed.
In your first case, the type inference algorithm gave "f : (int -> string) -> int -> string)" after it considered "x" but before it starts considering "y" (that step will then fail) and a long time before it considers your explicit type constraint.
In your second case, you splitted the statements in 2 blocks, the type inference algorithm is called twice (once per block), and this time your type constraint was considered before x and y are effectively typed.
-- Florent Ouchet PhD Student CIS/VDS Team - TIMA Laboratory _______________________________________________ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs