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 RAA27663; Sun, 11 Apr 2004 17:22:07 +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 RAA27711 for ; Sun, 11 Apr 2004 17:22:06 +0200 (MET DST) Received: from smtp.noos.fr (nan-smtp-20.noos.net [212.198.2.120]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i3BFN3jq027393 for ; Sun, 11 Apr 2004 17:23:03 +0200 Received: (qmail 16701 invoked by uid 0); 11 Apr 2004 15:22:04 -0000 Received: from unknown (HELO m223.net81-65-69.noos.fr) ([81.65.69.223]) (envelope-sender ) by 212.198.2.120 (qmail-ldap-1.03) with SMTP for ; 11 Apr 2004 15:22:04 -0000 From: nadji To: Jacques Garrigue Subject: Re: [Caml-list] Fwd: Polymorphic optional label argument, with default Date: Sun, 11 Apr 2004 17:23:14 +0200 User-Agent: KMail/1.6.1 Cc: rich@annexia.org, caml-list@inria.fr References: <20040410213616.GA28863@redhat.com> <20040411083357.GA19305@redhat.com> <20040411221619G.garrigue@kurims.kyoto-u.ac.jp> In-Reply-To: <20040411221619G.garrigue@kurims.kyoto-u.ac.jp> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: quoted-printable Message-Id: <200404111723.14238.nadji@noos.fr> 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; nadji:01 nadji:01 caml-list:01 2004:99 jacques:01 omitted:01 datatypes:01 analogous:01 'a-:01 ecrit:01 ocaml:01 phantom:01 int:01 int:01 garrigue:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk X-Status: X-Keywords: X-UID: 255 Le Sunday 11 April 2004 15:16, Jacques Garrigue a =E9crit : > Basically, what you are asking for is a new type of constraint, which > is only to be applied when the optional argument is omitted (and as > result the default is selected). > This is not possible in the current type system, and while there are > some uses for that, it would be hard to justify making types more > complex in the general case, just to handle this specific problem. I would like to point out that a machinery to handle this problem is guarded recursive datatypes proposed by Xi. It is a framework that solves a bunch of other problems and is compatible with ml type system (there is currently at Inria a student working on an Ocaml integrati= on=20 of this type system). Combining it with your labeled parameters leads to a well typed code analogous to your phantom-type based solution. Some even view Xi's GRDT as a way to avoid your Obj.magic when matching against=20 a phantom type.=20 =46or those interested, the pseudo code would be something like : guarded 'a opt =3D Omit with 'a =3D int | Arg of 'a->unit let plot : ?(labels:'a opt) -> 'a graph -> unit =3D fun ?(labels=3DOmit) g -> let printing_labels : 'a -> unit =3D=20 match labels with=20 Omit -> print_int | Arg x -> x in ... printing_labels node_label ... Nadji ------------------- 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