From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=AWL autolearn=disabled version=3.1.3 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id A4B6CBC6B for ; Sat, 4 Aug 2007 21:13:33 +0200 (CEST) Received: from einhorn.in-berlin.de (einhorn.in-berlin.de [192.109.42.8]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l74JDW51030430 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Sat, 4 Aug 2007 21:13:33 +0200 X-Envelope-From: oliver@first.in-berlin.de X-Envelope-To: Received: from einhorn.in-berlin.de (localhost [127.0.0.1]) by einhorn.in-berlin.de (8.13.6/8.13.6/Debian-1) with ESMTP id l74JDWfD009685 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Sat, 4 Aug 2007 21:13:32 +0200 Received: (from www-data@localhost) by einhorn.in-berlin.de (8.13.6/8.13.6/Submit) id l74JDWtY009683 for caml-list@inria.fr; Sat, 4 Aug 2007 21:13:32 +0200 X-Authentication-Warning: einhorn.in-berlin.de: www-data set sender to oliver@first.in-berlin.de using -f Received: from dslb-088-073-079-147.pools.arcor-ip.net (dslb-088-073-079-147.pools.arcor-ip.net [88.73.79.147]) by webmail.in-berlin.de (IMP) with HTTP for ; Sat, 4 Aug 2007 21:13:32 +0200 Message-ID: <1186254812.46b4cfdc2cef7@webmail.in-berlin.de> Date: Sat, 4 Aug 2007 21:13:32 +0200 From: Oliver Bandel To: Caml List Subject: Re: [Caml-list] Instanciating functor types with extra parameters References: <46B4A343.5030900@lix.polytechnique.fr> In-Reply-To: <46B4A343.5030900@lix.polytechnique.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.2.6 X-Scanned-By: MIMEDefang_at_IN-Berlin_e.V. on 192.109.42.8 X-Miltered: at concorde with ID 46B4CFDC.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; bandel:01 in-berlin:01 functor:01 lix:01 functor:01 orderedtype:01 sig:01 val:01 orderedtype:01 struct:01 sig:01 val:01 struct:01 ocamlc:01 innocent:98 Hello, Zitat von Arnaud Spiwack : > Hi caml list ! > > The recent, or rather current, thread on priority queues, raised back an > issue that've I've been really infuriated with a couple of time the > past, like, 2 years. > > When I have a functor type, like for example (not too innocent I'm afraid) : > > module type OrderedType = > sig > type t > val compare : t -> t -> int > end > > > Something that naive intuition would allow you to do is something like : > > module GenOrder : OrderedType = > struct > type t = 'a > let compare = compare > end [...] I don't know if this is flexible/generic enough for you, but at least for me it seems to be what you are looking for, and it compiles: =================================================== oliver@siouxsie2:~$ cat cmp.ml module type OT2 = sig type 'a t val compare: 'a t -> 'a t -> int end module GenOrder : OT2 = struct type 'a t = 'a let compare = compare end oliver@siouxsie2:~$ ocamlc -i cmp.ml module type OT2 = sig type 'a t val compare : 'a t -> 'a t -> int end module GenOrder : OT2 oliver@siouxsie2:~$ =================================================== Ciao, Oliver