From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id PAA03402; Thu, 29 Apr 2004 15:54:59 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id PAA03368 for ; Thu, 29 Apr 2004 15:54:58 +0200 (MET DST) Received: from mta1.cl.cam.ac.uk (mta1.cl.cam.ac.uk [128.232.0.15]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i3TDsvjq022742 for ; Thu, 29 Apr 2004 15:54:57 +0200 Received: from astrocyte.cl.cam.ac.uk ([128.232.8.107] helo=cl.cam.ac.uk ident=[FF2FWqiGqMK1zgluv9Fl7+o23cjMvoaD]) by mta1.cl.cam.ac.uk with esmtp (Exim 3.092 #1) id 1BJC08-0007xz-00; Thu, 29 Apr 2004 14:54:56 +0100 X-Mailer: exmh version 2.6.3-CL 04/04/2003 with nmh-1.0.4 X-Exmh-Isig-CompType: repl X-Exmh-Isig-Folder: cslists/caml To: Remi Vanicat cc: caml-list@inria.fr Subject: Re: [Caml-list] Documentation error - #myvariant In-reply-to: Your message of "Thu, 29 Apr 2004 14:40:37 +0200." <8765bjvtx6.dlv@vanicat.homelinux.org> Mime-Version: 1.0 Content-Type: text/plain Date: Thu, 29 Apr 2004 14:54:56 +0100 From: Keith Wansbrough Message-Id: X-Miltered: at nez-perce by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 supertype:01 misleading:01 passing:01 composing:01 monads:01 bool:01 bool:01 ocaml:01 variants:01 int:01 int:01 writes:01 remi:01 vanicat:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Rémi Vanicat writes: > The documentation is accurate. I think the documentation is unclear, and should be clarified. All the OCaml manual says is: "if you have defined type myvariant = [`Tag1 int | `Tag2 bool], then the pattern #myvariant is equivalent to writing (`Tag1(_ : int) | `Tag2(_ : bool))." This says nothing about how recursive types are treated when #myvariant occurs in a supertype context. Since this is surely a common use of polymorphic variants, it should at least say "the g1 / g example is misleading, as this #myvariant style won't work in most useful cases". > In fact, your code will do what you want if you don't define your type > as recursive but as polymorphic : OK - that type trick corresponds to the term trick already explained in the manual, with passing the recursive function explicitly. Shades of Steele, 1994, _Building Interpreters by Composing Monads_(!). Thanks.. --KW 8-) ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners