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 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 39640BC0A for ; Tue, 15 May 2007 17:41:23 +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 l4FFfLae021524 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 15 May 2007 17:41:22 +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 1Hnz9L-0005TU-FV for caml-list@yquem.inria.fr; Tue, 15 May 2007 16:41:20 +0100 From: "Josh Berdine" To: Subject: type aliases and recursive modules Date: Tue, 15 May 2007 16:40:57 +0100 Message-ID: <02bd01c79707$7b9d4c60$72d7e520$@qmul.ac.uk> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_02BE_01C7970F.DD642560" X-Mailer: Microsoft Office Outlook 12.0 thread-index: AceXB20YdG8fy57sRFOs2on61vBdAw== Content-Language: en-us X-DCS-Auth-User: berdine (person) X-j-chkmail-Score: MSGID : 4649D4A1.001 on discorde : j-chkmail score : XXX : 5/20 1 0.000 -> 3 X-Miltered: at discorde with ID 4649D4A1.001 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 typechecker:01 cheers:01 distilled:98 iym:98 distilled:98 This is a multipart message in MIME format. ------=_NextPart_000_02BE_01C7970F.DD642560 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 ------=_NextPart_000_02BE_01C7970F.DD642560 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Hi,

 

There’s something I’m not understanding = about recursive modules.  Consider the following distilled = example:

 

#

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 x)

end

;;

Characters 350-359:

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

           =             &= nbsp;           &n= bsp;    ^^^^^^^^^

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

  C.t =3D 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

------=_NextPart_000_02BE_01C7970F.DD642560--