From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 733E07F89E for ; Thu, 3 Apr 2014 20:18:06 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of yotambarnoy@gmail.com) identity=pra; client-ip=209.85.192.51; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="yotambarnoy@gmail.com"; x-sender="yotambarnoy@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of yotambarnoy@gmail.com designates 209.85.192.51 as permitted sender) identity=mailfrom; client-ip=209.85.192.51; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="yotambarnoy@gmail.com"; x-sender="yotambarnoy@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-qg0-f51.google.com) identity=helo; client-ip=209.85.192.51; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="yotambarnoy@gmail.com"; x-sender="postmaster@mail-qg0-f51.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Au4EAGClPVPRVcAzeGdsb2JhbABYg0FXrQCOBoh2gRcIFg4BFSYqgiUBAQEDAUABGxILAQMBCwYFCwMKDSEiAREBBQEKEgYTEgiHSgEDCQgNoBCMX4MOlw0KGScDCmSGUhEBBQyOYQQHhDgEmFuBNI8bGCmEeiE X-IPAS-Result: Au4EAGClPVPRVcAzeGdsb2JhbABYg0FXrQCOBoh2gRcIFg4BFSYqgiUBAQEDAUABGxILAQMBCwYFCwMKDSEiAREBBQEKEgYTEgiHSgEDCQgNoBCMX4MOlw0KGScDCmSGUhEBBQyOYQQHhDgEmFuBNI8bGCmEeiE X-IronPort-AV: E=Sophos;i="4.97,788,1389740400"; d="scan'208";a="66287875" Received: from mail-qg0-f51.google.com ([209.85.192.51]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 03 Apr 2014 20:18:05 +0200 Received: by mail-qg0-f51.google.com with SMTP id q108so2187370qgd.38 for ; Thu, 03 Apr 2014 11:18:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=oF+5Ze1IX0DeGIzo2WMwKLJDSDDXjrcxtyEJ1N2zzFk=; b=T8zKWtlDmB7SqlffOz48GkvijpbMslX3AZ4INmNR/iCJiQ4K2ILnmNFeO1PbPP9Ky0 qVBRWbQDI2ptmujiY2HJ8jVVfsmqLAIJxOD5z/iFr3fgAC0GOifEsegDqQmaNanejFLE dW8lio3geitIfvo+MTe+p/Zzxti6OD0NxYd3L8HMQp2R5XFiMyszdCaEknlCIccPWEeL or2/QEFzWa9nm0YdkkKgRpeoVIrsMB53Ta4SZmBOgwUiUhyfOfTCH7E8IPinwE6cfu// ujNnEdlMr6arIZekn4nvNRRvZBBy80jBl5+scJfxJA5oRKWzdRsLjJvsrLDoYWbjo83R oXNw== X-Received: by 10.224.92.75 with SMTP id q11mr9239263qam.56.1396549084622; Thu, 03 Apr 2014 11:18:04 -0700 (PDT) MIME-Version: 1.0 Received: by 10.224.213.132 with HTTP; Thu, 3 Apr 2014 11:17:44 -0700 (PDT) In-Reply-To: References: <20140403101410.GA3176@fuck_yeah> From: Yotam Barnoy Date: Thu, 3 Apr 2014 14:17:44 -0400 Message-ID: To: David Allsopp Cc: Ocaml Mailing List Content-Type: multipart/alternative; boundary=089e01493f1019d00904f6276c33 Subject: Re: [Caml-list] Ocaml compiler documentation --089e01493f1019d00904f6276c33 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Wow that was awesome! Thanks so much for your help and encouragement, guys! I think for this file I'll submit a simple PR with only a few minor clarifications for the less obvious features. I'll also make an 'OCaml Nuances' page in the wiki for listing some of these less well-known features. After that, I think I'll proceed to typing/typedtree.mli, which is the same AST, only after the typechecker has added types to it. On Thu, Apr 3, 2014 at 6:46 AM, David Allsopp wrote: > Simon Cruanes wrote: > > Le Thu, 03 Apr 2014, David Allsopp a =E9crit : > > > 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!) > > > > I might miss something, but wouldn't this be more readable if a variant > > was used instead of booleans? Say, > > > > type includes_constant =3D > > | IncludesConstant > > | DoesNotIncludeConstant > > Possibly (it certainly can't make any difference for efficiency, as type > bool is simply a two-constructor variant itself!). I guess historically t= he > worry would be conflicting names between different types, but that's not a > problem now. > > > In addition, I never heard about conjunctions in variants, so I'm happy > > Yotam started this initiative... > > +1! > > I already knew about conjunctions (it is worth perusing that section of > the manual as most, if not all, of the weird corner cases are covered in > there somewhere) but not how it was implemented in the parser/type checke= r! > > > David > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa.inria.fr/sympa/arc/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > --089e01493f1019d00904f6276c33 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Wow that was awesome! Thanks so much for your help an= d encouragement, guys!

I think for this file I'll submit a= simple PR with only a few minor clarifications for the less obvious featur= es. I'll also make an 'OCaml Nuances' page in the wiki for list= ing some of these less well-known features.

After that, I think I'll proceed to typing/typedtree.mli, which is = the same AST, only after the typechecker has added types to it.



On Thu, Apr= 3, 2014 at 6:46 AM, David Allsopp <dra-news@metastack.com> wrote:
Simon Cruanes wrote:
> Le Thu, 03 Apr 2014, David Allsopp a =E9crit :
> > Yotam Barnoy wrote:
> > > 2. What is demonstrated in lines 114-117 regarding polymorph= ic variant
> row fields:
> > >
> > >=A0 | Rtag of label * bool * core_type list
> > >=A0=A0=A0=A0=A0=A0=A0 (* [`A]=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0 ( true,=A0 [] )
> > >=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 [`A of T]=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0 ( false, [T] )
> > >=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 [`A of T1 & .. & Tn]= =A0=A0 ( false, [T1;...Tn] )
> > >=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 [`A of & T1 & .. &= Tn] ( true,=A0 [T1;...Tn] )
> > >=A0=A0=A0=A0=A0=A0=A0=A0 *)
> > >
> > > 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!)
>
> I might miss something, but wouldn't this be more readable if a va= riant
> was used instead of booleans? Say,
>
> type includes_constant =3D
> =A0 =A0 | IncludesConstant
> =A0 =A0 | DoesNotIncludeConstant

Possibly (it certainly can't make any difference for efficiency, = as type bool is simply a two-constructor variant itself!). I guess historic= ally the worry would be conflicting names between different types, but that= 's not a problem now.

> In addition, I never heard about conjunctions in variants, so I'm = happy
> Yotam started this initiative...

+1!

I already knew about conjunctions (it is worth perusing that section of the= manual as most, if not all, of the weird corner cases are covered in there= somewhere) but not how it was implemented in the parser/type checker!


David

--
Caml-list mailing list. =A0Subscription management and archives:
ht= tps://sympa.inria.fr/sympa/arc/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs
--089e01493f1019d00904f6276c33--