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.3 required=5.0 tests=AWL autolearn=disabled version=3.1.3 Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 4B1AABC0A for ; Tue, 15 May 2007 18:29:18 +0200 (CEST) Received: from smtp5-g19.free.fr (smtp5-g19.free.fr [212.27.42.35]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l4FGTHwX031168 for ; Tue, 15 May 2007 18:29:18 +0200 Received: from [192.168.1.111] (vil93-4-82-227-140-227.fbx.proxad.net [82.227.140.227]) by smtp5-g19.free.fr (Postfix) with ESMTP id BEA3D44369; Tue, 15 May 2007 18:29:17 +0200 (CEST) Message-ID: <4649DFDD.6040409@philippewang.info> Date: Tue, 15 May 2007 18:29:17 +0200 From: Philippe Wang User-Agent: Thunderbird 1.5.0.10 (Macintosh/20070221) MIME-Version: 1.0 To: Josh Berdine , ocaml ml Subject: Re: [Caml-list] type aliases and recursive modules References: <02bd01c79707$7b9d4c60$72d7e520$@qmul.ac.uk> In-Reply-To: <02bd01c79707$7b9d4c60$72d7e520$@qmul.ac.uk> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-Miltered: at discorde with ID 4649DFDD.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; recursive:01 recursive:01 sig:01 val:01 val:01 struct:01 sig:01 struct:01 typechecker:01 cheers:01 distilled:98 wrote:01 rec:01 workaround:01 caml-list:01 Josh Berdine wrote: > > Hi, > > There’s something I’m not understanding about recursive modules. > Consider the following distilled example: > > # > > module rec A : sig > > type t = It of ASet.t > > val compare : t -> t -> int > > val get : t -> ASet.t > > end = struct > > type t = It of ASet.t > > let compare = compare > > let get = function It(x) -> x > > end > > and ASet : sig > > type t > > val get_its_elements : t -> A.t list > > end = struct > > module C = Set.Make(A) > > type t = C.t > > let get_its_elements x = C.elements (A.get x) > > end > > ;; > > Characters 350-359: > > let get_its_elements x = C.elements (A.get x) > > ^^^^^^^^^ > > This expression has type ASet.t but is here used with type > > C.t = Set.Make(A).t > > # > > Why doesn’t the typechecker know that ASet.t and C.t are the same > type? Anyone know a workaround? > > This is with the 3.10.0 beta version, but seems to be the same back to > 3.07. > > Cheers, Josh > Hi, There is an incoherency in your definition of ASet.get_its_elements. In the signature of ASet, get_its_elements take an argument of type ASet.t, but then in its definition, it takes an argument of type A.t (as A.get takes an argument of type A.t, and you give ASet.get_its_elements' argument to A.get) -- Philippe Wang mail@philippewang.info