From: David Allsopp <dra-news@metastack.com>
To: Ocaml Mailing List <caml-list@inria.fr>
Subject: RE: [Caml-list] Ocaml compiler documentation
Date: Thu, 3 Apr 2014 09:05:43 +0000 [thread overview]
Message-ID: <E51C5B015DBD1348A1D85763337FB6D9E0946BE1@Remus.metastack.local> (raw)
In-Reply-To: <CAN6ygOks4OmN_1_9CoCwq5AsNgf+Sh=fKBNfC=1_cq2VuxP6dQ@mail.gmail.com>
Yotam Barnoy wrote:
> 2. What is demonstrated in lines 114-117 regarding polymorphic variant row fields:
>
> | Rtag of label * bool * core_type list
> (* [`A] ( true, [] )
> [`A of T] ( false, [T] )
> [`A of T1 & .. & Tn] ( false, [T1;...Tn] )
> [`A of & T1 & .. & Tn] ( true, [T1;...Tn] )
> *)
>
> What does the bool value represent?
It indicates that the constructor is constant, or that one of the types in the conjunction is "empty" (i.e. constant - I don't know what Jacques' terminology for that is!)
> Why are the type separators in the comments using the & symbol?
For example:
type t = [ `A of string & int ]
Error: The present constructor A has a conjunctive type
(see typing/typetexp.ml)
but, adapting "Advanced use" example in section 4.2 of the manual:
# let f x = (function `A x -> x = 1 | `B -> true) x && (function `A x -> x = "a" | `B -> true) x;;
val f : [< `A of string & int | `B ] -> bool = <fun>
in order to write an annotation:
# let f : [< `A of string & int | `B] ] -> bool = fun x -> ...
> What is the difference between the 3rd and 4th example?
The conjunction may include the constant constructor case:
# let f x = (function `A -> false | `B -> true) x && (function `A x -> x = "a" | `B -> true) x;;
val f : [< `A of & string | `B ] -> bool = <fun>
The constructor Reither will give you other pointers into where this information is needed in typing/typecore.ml.
HTH,
David
next prev parent reply other threads:[~2014-04-03 9:06 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-31 15:39 Yotam Barnoy
2014-03-31 17:06 ` Milan Stanojević
2014-03-31 17:51 ` Yotam Barnoy
2014-04-01 10:03 ` Mark Shinwell
2014-04-03 2:48 ` Yotam Barnoy
2014-04-03 6:18 ` Mark Shinwell
2014-04-03 8:42 ` Jeremy Yallop
2014-04-03 9:05 ` David Allsopp [this message]
2014-04-03 10:20 ` Simon Cruanes
2014-04-03 10:46 ` David Allsopp
2014-04-03 18:17 ` Yotam Barnoy
2014-04-03 9:10 ` Gabriel Scherer
2014-04-03 20:16 ` Alain Frisch
2014-04-04 7:39 ` François Bobot
2014-04-14 6:12 ` Mark Shinwell
2014-04-14 7:44 ` Alain Frisch
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=E51C5B015DBD1348A1D85763337FB6D9E0946BE1@Remus.metastack.local \
--to=dra-news@metastack.com \
--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