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 BAA27631; Sat, 28 Jun 2003 01:49:09 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id BAA27640 for ; Sat, 28 Jun 2003 01:49:08 +0200 (MET DST) Received: from smtpproxy2.mitre.org (smtpproxy2.mitre.org [192.80.55.70]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h5RNn3j04197 for ; Sat, 28 Jun 2003 01:49:03 +0200 (MET DST) Received: from avsrv2.mitre.org (avsrv2.mitre.org [128.29.154.4]) by smtpproxy2.mitre.org (8.12.9/8.12.8) with ESMTP id h5RMAt6r020816 for ; Fri, 27 Jun 2003 18:10:55 -0400 (EDT) Received: from MAILHUB1 (mailhub1.mitre.org [129.83.20.31]) by smtpsrv2.mitre.org (8.12.9/8.12.8) with ESMTP id h5RMAsOD006824 for ; Fri, 27 Jun 2003 18:10:54 -0400 (EDT) Received: from mm106599.mitre.org (129.83.35.12) by mailhub1.mitre.org with SMTP id 3170278; Fri, 27 Jun 2003 18:10:50 -0400 Message-ID: <3EFCC0E8.1070407@mitre.org> Date: Fri, 27 Jun 2003 18:10:48 -0400 From: Shaddin Doghmi User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.1) Gecko/20021003 X-Accept-Language: en-us, en MIME-Version: 1.0 To: "caml-list@inria.fr" Subject: Re: [Caml-list] syntax of private constructors in CVS version References: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; caml-list:01 brogoff:01 matchings:01 ledit:01 3.06:01 val:01 struct:01 snap:99 printf:01 bug:01 faq:01 beginner's:01 beginners:01 bin:01 caml-bugs:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk brogoff@speakeasy.net wrote: >On Fri, 27 Jun 2003, Shaddin Doghmi wrote: > > >> From the CVS version changes file, under language features: >> >>- Support for "private types", or more exactly concrete data types >> with private constructors or labels. These data types can be >> de-structured normally in pattern matchings, but values of these >> types cannot be constructed directly outside of their defining module. >> >>What is the syntax for those? is there some kind of documentation on the >>CVS server, like a development version of the manual or something? >> >> > >No documents are available yet. Check out the following: > >bpr@granite[bpr]$ ledit ~/bin/ocaml > Objective Caml version 3.06+36 (2003-06-19) > ># type t = private { x : int; y : int } ;; >type t = private { x : int; y : int; } ># type ('a, 'b) choice = private L of 'a | R of 'b;; >type ('a, 'b) choice = private L of 'a | R of 'b ># let p0 = { x = 0; y = 0 } ;; >One cannot create values of the private type t ># module Point2D : > sig > type t = private { x : int; y : int } > val grid : int > val mkPoint : int -> int -> t > end = > struct > type t = { x : int; y : int } > let grid = 10 > > let snap i = > let rem = i mod grid in > if rem <= 0 then > i - rem > else > i - rem + grid > > let mkPoint x y = { x = snap x; y = snap y } > end;; >module Point2D : > sig > type t = private { x : int; y : int; } > val grid : int > val mkPoint : int -> int -> t > end ># open Point2D;; ># match mkPoint 5 5 with { x = x; y = y } -> Printf.printf "(%d, %d)\n" x y;; >(10, 10) >- : unit = () > >-- Brian > >------------------- >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 > > neat. However, private doesnt seem to work with polymorphic variants(tried a bunch of variations of the syntax, nothing worked). Looking at the parser source seems to confirm that (i think ?), or am i missing something.... ------------------- 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