From: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
To: er@cs.brown.edu
Cc: yminsky@cs.cornell.edu, caml-list@inria.fr
Subject: Re: [Caml-list] Another polymorphism puzzle
Date: Fri, 01 Apr 2005 13:29:56 +0900 (JST) [thread overview]
Message-ID: <20050401.132956.74753023.garrigue@math.nagoya-u.ac.jp> (raw)
In-Reply-To: <20050401025205.GA4723@cs.brown.edu>
From: Manos Renieris <er@cs.brown.edu>
> Worse:
>
> # let f x = { () with foo = 3};;
> val f : 'a -> int t = <fun>
> # let f x = { 42 with foo = 3};;
> val f : 'a -> int t = <fun>
>
> I think this qualifies as a bug. Especially since the documentation
> says the expr on the left hand side of with has to be a record.
What do you mean by worse? You just exhibit an immediate consequence
of the typing of f below.
> Thu, Mar 31, 2005 at 09:02:14PM -0500, Yaron Minsky wrote:
> > # type 'a t = { foo: 'a };;
> > type 'a t = { foo : 'a; }
> > # let f x = { x with foo = 3 };;
> > val f : 'a -> int t = <fun>
Now, why does it happen?
The reason is simply that the typing of {x with fields} follows
closely its semantics:
build a record from the given fields, extracting values from x
when a field is missing.
Consequence: if you provide all the fields, then there is no missing
field, so x can be completely ignored.
Following the manual, the typing could be more restrictive, but the
current typing is perfectly sound.
Jacques Garrigue
next prev parent reply other threads:[~2005-04-01 4:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-04-01 2:02 Yaron Minsky
2005-04-01 2:32 ` [Caml-list] " Karl Zilles
2005-04-01 2:52 ` Manos Renieris
2005-04-01 4:29 ` Jacques Garrigue [this message]
2005-04-01 9:45 ` Alex Baretta
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=20050401.132956.74753023.garrigue@math.nagoya-u.ac.jp \
--to=garrigue@math.nagoya-u.ac.jp \
--cc=caml-list@inria.fr \
--cc=er@cs.brown.edu \
--cc=yminsky@cs.cornell.edu \
/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