restricted let-polymorphism with mutable references (ref) • polymorphic params (rank-n polymorphism) • algorithm complexity is exponential; not a problem in practice
= ref NONE val r1 : string option ref = r0 val r2 : int option ref = r0 val _ = r1 := SOME "foo" val v : int = valOf (!r2) The string inside is used as an int. ERROR
= ref NONE val r1 : string option ref = r0 val r2 : int option ref = r0 val _ = r1 := SOME "foo" val v : int = valOf (!r2) Solved in OCaml using weak polymorphism. Type is polymorphic until first use; afterwards becomes monomorphic. ERROR