On 24/01/18 08:43, Jacques Garrigue wrote:
I.e., types can be used to optimize a program, but they do not change its semantics.
It’s true of so-called “overloaded” record labels, it’s true of a labeled and default arguments
(which use type information for compilation, but not semantics), it’s true of objects,
it’s true of GADT pattern-matching (again optimized), etc…
type foo = { x : int }
type bar = { x : string }
let f r = r.x (* OK: uses bar *)
let f r = (r:foo).x (* OK: uses foo *)
let f r = (r.x : int) (* type error - wrong type inferred *)
Aren't the semantics different? 'f' has different types in the first two definitions, And why does type inference fail for the last example?
Toby
--
Caml-list mailing list. Subscription management and archives:
https://sympa.inria.fr/sympa/arc/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs