caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Shaddin Doghmi <shaddin@mitre.org>
To: "caml-list@inria.fr" <caml-list@inria.fr>
Subject: Re: [Caml-list] syntax of private constructors in CVS version
Date: Fri, 27 Jun 2003 18:10:48 -0400	[thread overview]
Message-ID: <3EFCC0E8.1070407@mitre.org> (raw)
In-Reply-To: <Pine.LNX.4.44.0306271400550.15243-100000@grace.speakeasy.net>

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


  reply	other threads:[~2003-06-27 23:49 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-27 20:50 Shaddin Doghmi
2003-06-27 21:15 ` brogoff
2003-06-27 22:10   ` Shaddin Doghmi [this message]
2003-06-28  2:24     ` brogoff
2003-06-30 18:39       ` Pierre Weis
2003-06-30 19:00         ` Chris Hecker
2003-06-30 21:36           ` brogoff
2003-07-01 10:47           ` Pierre Weis
2003-07-01  7:43         ` Hendrik Tews
2003-07-01 10:37         ` Yaron M. Minsky
2003-07-01 10:51         ` Yaron M. Minsky
2003-07-01 17:05           ` Pierre Weis
2003-07-01 17:20             ` brogoff
2003-07-03 11:46         ` John Max Skaller
2003-07-07 22:31           ` Pierre Weis
2003-07-13  9:11             ` John Max Skaller
2003-07-15  8:02               ` Laurent Vibert
2003-07-15  8:22                 ` Pierre Weis

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=3EFCC0E8.1070407@mitre.org \
    --to=shaddin@mitre.org \
    --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;
as well as URLs for NNTP newsgroup(s).