From: Ben Millwood <bmillwood@janestreet.com>
To: Jean Saint-Remy <jeansaintremy@yahoo.com>
Cc: "caml-list@inria.fr" <caml-list@inria.fr>
Subject: Re: [Caml-list] explicit polymorphic types in record fields
Date: Mon, 16 Feb 2015 13:39:13 +0000 [thread overview]
Message-ID: <CA+MHO50JC3OBPv-RknvFMfiU2neyOh_oYHoZYMScEcMf5c8PJg@mail.gmail.com> (raw)
In-Reply-To: <419599633.6386715.1424045192831.JavaMail.yahoo@mail.yahoo.com>
[-- Attachment #1: Type: text/plain, Size: 1332 bytes --]
Gerd's reply covers most of the important points. I just wanted to add:
On 16 February 2015 at 00:06, Jean Saint-Remy <jeansaintremy@yahoo.com>
wrote:
> I could not declare the fields for example as a polymorphic tuple for
> instance: "type idref = { mutable 'a * 'b -> 'a }" nor "type idref = {
> mutable 'a. 'b -> 'a }". The latter is just nonsense, the 'b is undefined.
> But we could have a two field record by just repeating the type
> definitions. "let idref = { mutable 'a. 'a -> 'a; mutable 'b. 'b -> 'b }".
> The polymorphic type does not have any restriction, it appears we could
> have any fundamental type we wanted. The type 'a variable must be repeated,
> it is not enough to say "type idref = { mutable 'a. -> 'a };;" Is it
> correct then to read the declaration in this way: the type 'a polymorphic
> type as a polymorphic variable of type 'a. I know it sounds redundant, but
> that is how I am reading the syntax.
>
All the pieces of record syntax in this quoted paragraph are missing a
field name. Where you say things like "type idref = { mutable 'a * 'b -> 'a
}", you probably mean something like "type idref = { mutable fst : 'a 'b .
'a * 'b -> 'a }" -- notice the name of the field, followed by the colon,
which always comes before the type, including any 'a . -style variable
bindings it might start with.
[-- Attachment #2: Type: text/html, Size: 1992 bytes --]
prev parent reply other threads:[~2015-02-16 13:39 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-16 0:06 Jean Saint-Remy
2015-02-16 13:14 ` Gerd Stolpmann
2015-02-16 13:15 ` Gerd Stolpmann
2015-02-16 13:39 ` Ben Millwood [this message]
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=CA+MHO50JC3OBPv-RknvFMfiU2neyOh_oYHoZYMScEcMf5c8PJg@mail.gmail.com \
--to=bmillwood@janestreet.com \
--cc=caml-list@inria.fr \
--cc=jeansaintremy@yahoo.com \
/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