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 XAA17363; Sat, 10 Apr 2004 23:36:18 +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 XAA17530 for ; Sat, 10 Apr 2004 23:36:17 +0200 (MET DST) Received: from aomori.annexia.org (annexia.force9.co.uk [212.56.101.183]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i3ALaGYM004979 for ; Sat, 10 Apr 2004 23:36:17 +0200 Received: from rich by aomori.annexia.org with local (Exim 3.36 #1 (Debian)) id 1BCQ9A-0007Vx-00 for ; Sat, 10 Apr 2004 22:36:16 +0100 Date: Sat, 10 Apr 2004 22:36:16 +0100 To: caml-list@inria.fr Subject: [Caml-list] Fwd: Polymorphic optional label argument, with default Message-ID: <20040410213616.GA28863@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.5.1+cvs20040105i From: Richard Jones X-Miltered: at concorde by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; beginners:01 api:01 beginners:01 type-safe:01 ltd:98 ocaml:01 ocaml:01 caml:01 caml:01 int:01 int:01 labels:01 labels:01 polymorphic:01 polymorphic:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk X-Status: X-Keywords: X-UID: 232 Hi: I posted the message below originally on ocaml_beginners. There were many helpful responses, and the general consensus was that this was not possible, but no one could give a definitive answer. I just wanted to confirm on the 'grown-ups' list (:-) if this is really true before I finalise the API I am designing. Thanks, Rich. To: ocaml_beginners@yahoogroups.com From: Richard Jones Subject: Polymorphic optional label argument, with default I have a function defined: let plot ?(labels = string_of_int) graph = (* ... *) The idea of the optional 'labels' argument is to specify a polymorphic function 'a -> string which is used to print labels stored in the 'graph' argument. The problem is that because string_of_int is obviously int -> string, my function is typed as: plot : ?labels : (int -> string) -> (* ... int ... *) -> unit but I want it to be typed as: plot : ?labels : ('a -> string) -> (* ... 'a ... *) -> unit [The 'a types are the same type. If I leave out the initializer, then it works.] How to? Rich. -- Richard Jones. http://www.annexia.org/ http://www.j-london.com/ Merjis Ltd. http://www.merjis.com/ - improving website return on investment Perl4Caml lets you use any Perl library in your type-safe Objective CAML programs. http://www.merjis.com/developers/perl4caml/ ------------------- 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