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 <dra-news@metastack.com> wrote:
Simon Cruanes wrote:
> Le Thu, 03 Apr 2014, David Allsopp a écrit :
> > 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 =
>     | 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 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.  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