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 mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by sympa.inria.fr (Postfix) with ESMTPS id 2BAF97ED26 for ; Fri, 8 Jun 2012 01:37:24 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ap4EAAQ60U+FBoIF/2dsb2JhbABFhVCwBIIYAQEEASMdAwE1AQEDCwsaAhgOAgJXBogZBKVYboNGAYYGiH0BBoEjjmgyYIhBjF+PeoJv X-IronPort-AV: E=Sophos;i="4.75,733,1330902000"; d="scan'208";a="146966461" Received: from rabbit.math.nagoya-u.ac.jp (HELO mailhost.math.nagoya-u.ac.jp) ([133.6.130.5]) by mail4-smtp-sop.national.inria.fr with ESMTP; 08 Jun 2012 01:37:22 +0200 Received: from mailhost.math.nagoya-u.ac.jp (localhost [127.0.0.1]) by mailhost.math.nagoya-u.ac.jp (Postfix) with ESMTP id E39E2630F; Fri, 8 Jun 2012 08:37:19 +0900 (JST) Received: from mailhost.math.nagoya-u.ac.jp (camel-172.math.nagoya-u.ac.jp [172.16.254.4]) by mailhost.math.nagoya-u.ac.jp (Postfix) with ESMTP id A7F9140C8; Fri, 8 Jun 2012 08:37:19 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=math.nagoya-u.ac.jp; h= subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; s=alpha; bh=/z13zu4LoqJkC811hkSL4mpp7lA=; b=PsGzkqJW00k5eSkD+YBiB+9Gk+Lv Jf2kjMfolglmm70gRYMKkTkBrsMFS1anKQyBUhK6XqO9fK7tI+G8rveWM9S9o6+r 6Oxk3oUohzlhuYyYDIY58mFDbpQmnvGhNePvq/Dh2tO7PO+zf/tR8HTF0KhSvWHR 1tspj/mrWzmJuhY= DomainKey-Signature: a=rsa-sha1; h=Received:Subject:Mime-Version:Content-Type:From:In-Reply-To:Date:Cc:Content-Transfer-Encoding:Message-Id:References:To:X-Mailer; b=r0dg8PpfP2C9tyQIxqVmnsTcj9+PvqnRsl/yodtsaxGtkm+7Njy1edF4zF7AelMGmUKuV8p9ob65UZtQr1BCEr/DEeaYB+w4EKQfxFYP5azVUUs+8BaZo/MOYjcXSQMyrdlzxFQ3reXcDzu+rVjCB2Rr+ZTA2aCsqDmZg7yD42s=; c=nofws; d=math.nagoya-u.ac.jp; q=dns; s=alpha Received: from tet.garrigue.jp (58x158x128x157.ap58.ftth.ucom.ne.jp [58.158.128.157]) by mailhost.math.nagoya-u.ac.jp (Postfix) with ESMTPSA id 593F040C3; Fri, 8 Jun 2012 08:37:19 +0900 (JST) Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=utf-8 From: Jacques Garrigue In-Reply-To: Date: Fri, 8 Jun 2012 08:37:18 +0900 Cc: Markus Mottl , Caml List Content-Transfer-Encoding: quoted-printable Message-Id: <5ECBEDB2-9C7C-45B7-98F7-36E10B2BB07D@math.nagoya-u.ac.jp> References: To: =?utf-8?Q?Milan_Stanojevi=C4=87?= X-Mailer: Apple Mail (2.1084) Subject: Re: [Caml-list] strange error with packed modules and module type of On 2012/06/08, at 4:53, Milan Stanojevi=C4=87 wrote: > If I just do > ocamlopt.opt -for-pack G -c foo.mli foo.ml > ocamlopt.opt -pack -o g.cmx foo.cmx >=20 > that is, forget all the fancyness with std and specifying interface > for G, the resulting G module has the type > sig module Foo : sig type t =3D G.Foo.t val x : t end end >=20 > So somehow the resulting interface of G is defined in terms of itself?! >=20 > Should I just file this problem on ocaml mantis? This is the right behavior. To understand it, you should distinguish between the interface (or abstract= signature) and the concrete type of a module (its strengthened signature). The above type is not the interface of G (which of course should not refer = to itself by name) but its strengthened signature (its exact type). Since an abstract signature has a meaning independently of the module you u= se it for, it is strengthened so that the abstract components of the interface refer explicitly to the module. See this dialogue: # module M : sig type t val x : int end =3D struct type t =3D int let x =3D= 1 end;; module M : sig type t val x : int end # module N =3D M;; module N : sig type t =3D M.t val x : int end > p.s the only way I was able to get interface for G is to make a helper > program that uses G with a wrong signature and get the compiler to > give me the type in the error message. Is there a better way? As shown above, you can define another module as an alias. It will give you the strengthened signature for your original module. You can also see its abstract signature, using "module type of". # module type S =3D module type of M;; module type S =3D sig type t val x : int end Jacques Garrigue=