From: Markus Mottl <mottl@miss.wu-wien.ac.at>
To: caml-list@inria.fr (OCAML)
Subject: typing, records and "with"
Date: Sat, 4 Sep 1999 17:50:19 +0100 (MET DST) [thread overview]
Message-ID: <199909041550.RAA18090@miss.wu-wien.ac.at> (raw)
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
reply other threads:[~1999-09-06 8:26 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=199909041550.RAA18090@miss.wu-wien.ac.at \
--to=mottl@miss.wu-wien.ac.at \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox