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=2.1 required=5.0 tests=AWL,DNS_FROM_RFC_ABUSE, SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 7FCA5BC4F for ; Wed, 13 Sep 2006 11:48:39 +0200 (CEST) Received: from qb-out-0506.google.com (qb-out-0506.google.com [72.14.204.237]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id k8D9mcIl007586 for ; Wed, 13 Sep 2006 11:48:39 +0200 Received: by qb-out-0506.google.com with SMTP id c7so649831qbc for ; Wed, 13 Sep 2006 02:48:38 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=guxNYK5N8/N4SSEmimB5A6TabxjlPh6Zhcj3gLOTAf93jQ/KBLNQrwFNuXU45Af5LS9EFf0o4Mc5fTzDEbb8pQcDQ3N/92Pr2IivTCGNSlJOkBHq4hhJ4/KWTYzCUpsTHspKP30iXE0ul/fHJnVnkZwlHbU4N4sNEhCbU75HoS4= Received: by 10.70.30.5 with SMTP id d5mr10093360wxd; Wed, 13 Sep 2006 02:48:37 -0700 (PDT) Received: by 10.70.84.13 with HTTP; Wed, 13 Sep 2006 02:48:37 -0700 (PDT) Message-ID: Date: Wed, 13 Sep 2006 21:48:37 +1200 From: "Jonathan Roewen" To: "Martin Hofmann" Subject: Re: [Caml-list] Modules within classes Cc: caml-list@inria.fr, Oliver.Friedmann@web.de In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: X-j-chkmail-Score: MSGID : 4507D3F6.000 on concorde : j-chkmail score : X : 0/20 1 X-Miltered: at concorde with ID 4507D3F6.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; traversing:01 mhofmann:01 struct:01 ocaml:01 pervasives:01 beginner's:01 ocaml:01 bug:01 beginners:01 unbound:01 wrote:01 wrote:01 oliver:01 workaround:01 workaround:01 As for a workaround, use List.sort. I presume there's a real reason to want to use Set rather than the contrived example given though... if not, then there's your solution (= Jonathan PS: The order of traversing the list doesn't seem to be of much significance, so List.fold_left might be better suited. On 9/13/06, Jonathan Roewen wrote: > It's the same at normal scope: > > type t = 'a;; doesn't compile. > > you need: type 'a t = 'a, which isn't compatible with input type for Set. > > I think the Set module is intentionally monomorphic... > > Jonathan > > On 9/13/06, Martin Hofmann wrote: > > Dear all, > > > > Can someone explain what is wrong here and perhaps suggest a workaround? > > > > class ['a] test ( l : 'a list) = > > object > > method result = > > let module M = > > struct > > type t = 'a > > let compare x y = > > if x < y then -1 else if x > y then 1 else 0 > > end > > in > > let module MSet = Set.Make(M) > > in MSet.elements (List.fold_right MSet.add l MSet.empty) > > end;; > > > > OCaml says: "Unbound type parameter 'a". > > > > Our aim is of course not to program sorting the umpteenth time but to > > have a means for using Pervasives.Set within a parametrised class. > > > > The problem seems to be that although "class ['a]" binds 'a its use is > > nevertheless disallowed in the scope of the class declaration. > > > > Many thanks in advance! > > > > Martin Hofmann (on behalf of Oliver Friedmann) > > > > _______________________________________________ > > Caml-list mailing list. Subscription management: > > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > > Archives: http://caml.inria.fr > > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > > Bug reports: http://caml.inria.fr/bin/caml-bugs > > >