From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id F0C997EE25 for ; Thu, 13 Jun 2013 22:22:04 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of nuffer@gmail.com) identity=pra; client-ip=209.85.212.46; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="nuffer@gmail.com"; x-sender="nuffer@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of nuffer@gmail.com designates 209.85.212.46 as permitted sender) identity=mailfrom; client-ip=209.85.212.46; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="nuffer@gmail.com"; x-sender="nuffer@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-vb0-f46.google.com) identity=helo; client-ip=209.85.212.46; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="nuffer@gmail.com"; x-sender="postmaster@mail-vb0-f46.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AkkBAAcpulHRVdQuk2dsb2JhbABbhAK/NwgWDgEBAQEHCxQUBCSCURkBGx4DEgkBBl0BEQEFAYgwAQMPmm6CfoxLgn+EYQoZJw1Yh3QBBQyPVINKA5dBj10WKYRRIA X-IPAS-Result: AkkBAAcpulHRVdQuk2dsb2JhbABbhAK/NwgWDgEBAQEHCxQUBCSCURkBGx4DEgkBBl0BEQEFAYgwAQMPmm6CfoxLgn+EYQoZJw1Yh3QBBQyPVINKA5dBj10WKYRRIA X-IronPort-AV: E=Sophos;i="4.87,861,1363129200"; d="scan'208";a="21729927" Received: from mail-vb0-f46.google.com ([209.85.212.46]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 13 Jun 2013 22:22:04 +0200 Received: by mail-vb0-f46.google.com with SMTP id 10so7372125vbe.33 for ; Thu, 13 Jun 2013 13:22:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=sVGJOQn0U99nN2P58+/64dJy6E9udSxHo6ORIHXNJQY=; b=OO+9WAYUEIl0CFBJ1Q1Pl5iSJYemlHwroQ2CrxYIoyVJamBxcOpsMiWnmW20iXJvIk QR6QmlftCph7pLUXtcWJpO2fxLWi+ey/MH6VwqB8oD9V2AWXfyLCuvj8NxXTDBX9Fsqi 7JFjX3yNZ101u8sWjgnr/xKJb+TGScZSxeyQO8vtwSevcygPilXMaQkmrw8GcQwtqK3G 8fa3vtShg/h2Wf41EqT57lgX/wyd0pg+JyVYWQKKu68RINAJg8S971ZEl+M6JIzX5rNC VkjbNuwBG0wKp+67ixTONaU1p/CgnIKu8Y7d1pSL9G6mOR4+NNbOwi9mT5gVvSu30oEB GGqw== MIME-Version: 1.0 X-Received: by 10.59.1.196 with SMTP id bi4mr987562ved.45.1371154923409; Thu, 13 Jun 2013 13:22:03 -0700 (PDT) Received: by 10.58.255.72 with HTTP; Thu, 13 Jun 2013 13:22:03 -0700 (PDT) Date: Thu, 13 Jun 2013 16:22:03 -0400 Message-ID: From: Daniel Nuffer To: caml-list@inria.fr Content-Type: multipart/alternative; boundary=047d7bf0efd824586404df0ee29b Subject: [Caml-list] Strange type error with recursive modules --047d7bf0efd824586404df0ee29b Content-Type: text/plain; charset=ISO-8859-1 Can anyone explain why this does not compile: module rec A : sig type t end = struct type z = { x : B.t } type t = z let foo t = B.foo t.x t (* Error: This expression has type t but an expression was expected of type A.t *) end and B : sig type t val foo : B.t -> A.t -> unit end = struct type t let foo _ _ = () end Note that if there's no type aliasing in A, it will succeed: module rec A : sig type t end = struct type t = { x : B.t } let foo t = B.foo t.x t end and B : sig type t val foo : B.t -> A.t -> unit end = struct type t let foo _ _ = () end Thanks! --047d7bf0efd824586404df0ee29b Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Can anyone explain why this does not compile:

module rec A : sig
=A0 type t
end =3D struc= t
=A0 type z =3D { x : B.t }

=A0 type t = =3D z

=A0 let foo t =3D B.foo t.x t (* Error:=A0This expressi= on has type t but an expression was expected of type A.t *)
end

and B : sig
=A0 type t
=A0 val = foo : B.t -> A.t -> unit
end =3D struct
=A0 type t
=A0 let foo _ _ =3D ()
end

Note that if there's = no type aliasing in A, it will succeed:


module rec A : sig
=A0 type t
end =3D st= ruct
=A0 type t =3D { x : B.t }

=A0 let = foo t =3D B.foo t.x t
end

and B : sig
=A0 type t
=A0 val foo : B.t -> A.t -> unit
end = =3D struct
=A0 type t
=A0 let foo _ _ =3D ()
= end

Thanks!
--047d7bf0efd824586404df0ee29b--