From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 399C9BB81 for ; Thu, 11 Nov 2004 10:11:26 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id iAB9BPMG027197 for ; Thu, 11 Nov 2004 10:11:25 +0100 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 KAA03520 for ; Thu, 11 Nov 2004 10:11:25 +0100 (MET) Received: from mail.rsise.anu.edu.au (mail.rsise.anu.edu.au [150.203.208.4]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id iAB9BLKA027191 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Thu, 11 Nov 2004 10:11:24 +0100 Received: from localhost (localhost [127.0.0.1]) by mail.rsise.anu.edu.au (Postfix) with ESMTP id 6FC9116570 for ; Thu, 11 Nov 2004 20:11:19 +1100 (EST) Received: from mail.rsise.anu.edu.au ([150.203.208.4]) by localhost (mail [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 18117-09 for ; Thu, 11 Nov 2004 20:11:19 +1100 (EST) Received: from pulp.anu.edu.au (pulp.rsise.anu.edu.au [150.203.208.49]) by mail.rsise.anu.edu.au (Postfix) with ESMTP id 5F0801651F for ; Thu, 11 Nov 2004 20:11:19 +1100 (EST) Received: by pulp.anu.edu.au (Postfix, from userid 1560) id F32F725B791; Thu, 11 Nov 2004 20:09:31 +1100 (EST) Date: Thu, 11 Nov 2004 20:09:31 +1100 From: Pietro Abate To: ocaml ml Subject: Re: [Caml-list] module type... Message-ID: <20041111090931.GA13972@pulp.anu.edu.au> Mail-Followup-To: Pietro Abate , ocaml ml References: <20041111083547.GA13116@pulp.anu.edu.au> <1100163369.2579.70.camel@pelican.wigram> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1100163369.2579.70.camel@pelican.wigram> X-Operating-System: GNU/Linux X-Organization: Research School of Information Science and Engineering (Australian National University) User-Agent: Mutt/1.5.6+20040907i X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at mail.rsise.anu.edu.au X-Miltered: at concorde with ID 41932CBD.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 41932CB9.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; anu:01 caml-list:01 wrote:01 coerced:01 'int':01 functor:01 elt:01 functor:01 struct:01 struct:01 functors:01 sig:01 val:01 val:01 sig:01 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.0 X-Spam-Level: Thanks John. On Thu, Nov 11, 2004 at 07:56:10PM +1100, skaller wrote: > By coercing TermType to ElType, you have coerced 'int' to 't', > where 't' is an abstract type, in other words the coercion is hiding > the representation. There are two ways around this ok, I got the problem... but neither of your solutions solve my more general problem as I need ElType.t to be an abstract data type as I'm using it in a functor... now it says: This expression has type int but is here used with type SetOfTerm.Set.elt = TermType.t for the same reason as before, but I can't change the ElType.t without breaking the functor [....] module MakeSet = functor (Q : ElType) -> functor (SetFunc : SetFuncType) -> struct module Set = SetFunc ( struct type t = Q.t let compare = compare end ) [....] below the extended version of the problem with the same error... any advice on how to modify my modules/classes design to overcome this problem ? what I'm trying to do is to have set, setofset, setofsetofset etc using the same code base and functors... :) p -------------------------------- module type ElType = sig type t val copy : t -> t val to_string : t -> string end module type OrderedType = sig type t val compare : t -> t -> int end module type SetFuncType = functor (Ord : OrderedType) -> sig type elt = Ord.t type t val empty : t val compare : t -> t -> int val add : elt -> t -> t end module MakeSet = functor (Q : ElType) -> functor (SetFunc : SetFuncType) -> struct module Set = SetFunc ( struct type t = Q.t let compare = compare end ) class set ?(el=[]) () = object(self) initializer self#add el val mutable s = Set.empty method add el = s <- List.fold_left ( fun s' e -> Set.add e s' ) s el end end module TermType : ElType = struct type t = int let copy t = t let to_string t = "this is a string" end ;; module SetOfTerm = MakeSet (TermType) (Set.Make);; (* ------------------ *) module SetOfTermType : ElType = struct type t = SetOfTerm.set let copy t = t let to_string t = "this is an other string" end ;; module SetOfSet = MakeSet (SetOfTermType) (Set.Make);; let newset_naked ?(el=[]) () = new SetOfTerm.set ~el:el let newset ?(el=[]) () = (`Set (new SetOfTerm.set ~el:el)) let newsetofset ?(el=[]) () = (`Set (newset ~el:el ())) let a = newset_naked ~el:[1;2] ();; let b = newsetofset ~el:[a] ();; -- ++ "All great truths begin as blasphemies." -George Bernard Shaw ++ Please avoid sending me Word or PowerPoint attachments. See http://www.fsf.org/philosophy/no-word-attachments.html