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,HTML_MESSAGE 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 A2DCBBC0A for ; Tue, 15 May 2007 18:57:06 +0200 (CEST) Received: from mail.dcs.qmul.ac.uk (tart.dcs.qmul.ac.uk [138.37.95.139]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l4FGv4re004358 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 15 May 2007 18:57:05 +0200 Received: from tide95.microsoft.com ([213.199.128.153] helo=msrc1291015) by mail.dcs.qmul.ac.uk with esmtpsa (TLSv1:RC4-MD5:128) (Exim 4.62) (envelope-from ) id 1Ho0Kc-0006fx-Vk for caml-list@inria.fr; Tue, 15 May 2007 17:57:04 +0100 From: "Josh Berdine" To: "'ocaml ml'" References: <02bd01c79707$7b9d4c60$72d7e520$@qmul.ac.uk> <4649DFDD.6040409@philippewang.info> In-Reply-To: <4649DFDD.6040409@philippewang.info> Subject: RE: [Caml-list] type aliases and recursive modules Date: Tue, 15 May 2007 17:56:55 +0100 Message-ID: <02d701c79712$0fbb09f0$2f311dd0$@qmul.ac.uk> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_02D8_01C7971A.717F71F0" X-Mailer: Microsoft Office Outlook 12.0 thread-index: AceXDsQtSwfYe4MSRRGOa8F7b38GeQAAiD8w Content-Language: en-us X-DCS-Auth-User: berdine (person) X-j-chkmail-Score: MSGID : 4649E660.000 on discorde : j-chkmail score : XXX : 5/20 1 0.000 -> 3 X-Miltered: at discorde with ID 4649E660.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; recursive:01 recursive:01 typechecker:01 cheers:01 sig:01 val:01 val:01 struct:01 sig:01 struct:01 cheers:01 typechecker:01 distilled:98 iym:98 distilled:98 This is a multipart message in MIME format. ------=_NextPart_000_02D8_01C7971A.717F71F0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hi, Josh Berdine wrote: > > Hi, > > There's something I'm not understanding about recursive modules. > Consider the following distilled example: > [snip buggy simplification] > > 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 Thanks Philippe and Christopher, yes, mea culpa, I forgot, e.g., a call to choose. But my confusion remains: # 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 (C.choose x)) end ;; Characters 350-370: let get_its_elements x = C.elements (A.get (C.choose x)) ^^^^^^^^^^^^^^^^^^^^ This expression has type ASet.t but is here used with type C.t = Set.Make(A).t # Am I still doing something stupid? Cheers, Josh ------=_NextPart_000_02D8_01C7971A.717F71F0 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Hi,

 

Josh Berdine = wrote:

> 

> = Hi,

> 

> There’s = something I’m not understanding about recursive modules.

> Consider the = following distilled example:

> 

 

      [snip buggy = simplification]

 

> 

> 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

 

 

Thanks = Philippe and Christopher, yes, mea culpa, I forgot, e.g., a call to = choose.  But my confusion remains:

 

 

# =

module rec A : = sig

  type t =3D It = of ASet.t

  val compare : = t -> t -> int

  val get : t = -> ASet.t

end =3D = struct

  type t =3D It = of ASet.t

  let compare = =3D compare

  let get =3D = function It(x) -> x

end

 

and ASet : = sig

  type = t

  val = get_its_elements : t -> A.t list

end =3D = struct

  module C =3D = Set.Make(A)

  type t =3D = C.t

  let = get_its_elements x =3D C.elements (A.get (C.choose x))

end

;;

        &nb= sp;           &nbs= p;            = ;     Characters 350-370:

    = let get_its_elements x =3D C.elements (A.get (C.choose = x))

        &nb= sp;           &nbs= p;            = ;       ^^^^^^^^^^^^^^^^^^^^

This expression has = type ASet.t but is here used with type

  C.t =3D = Set.Make(A).t

#

 

 

Am I still doing = something stupid?

 

Cheers,  = Josh

------=_NextPart_000_02D8_01C7971A.717F71F0--