* typing, records and "with"
@ 1999-09-04 16:50 Markus Mottl
0 siblings, 0 replies; only message in thread
From: Markus Mottl @ 1999-09-04 16:50 UTC (permalink / raw)
To: OCAML
Hello,
it seems that the inferred type in combination with the "with" construct
(records) could sometimes be more general. Eg.:
type 'a t = {a : 'a; b : int}
let x = {a = 1; b = 2}
let y = {x with a = "1"}
This leads to the following error:
File "bla.ml", line 4, characters 9-10:
This expression has type int t but is here used with type string t
But everything is fine with the following binding of y:
let y = {a = "1"; b = x.b}
Maybe 'a shouldn't be bound to the type parameter of the "source record"
within the "with" construct, but checked only against the "general"
type for consistency - this would find errors as in:
type 'a t = {a : 'a; b : 'a}
let x = {a = 1; b = 2}
let y = {x with a = "1"}
Regards,
Markus Mottl
--
Markus Mottl, mottl@miss.wu-wien.ac.at, http://miss.wu-wien.ac.at/~mottl
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1999-09-06 8:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-09-04 16:50 typing, records and "with" Markus Mottl
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox