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=1.0 required=5.0 tests=AWL,SPF_FAIL autolearn=disabled version=3.1.3 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 9CBB9BC6B for ; Fri, 11 Jan 2008 23:55:35 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAByCh0fAXQInh2dsb2JhbACQDAEBAQgKKZlT X-IronPort-AV: E=Sophos;i="4.24,273,1196636400"; d="scan'208";a="7719409" Received: from concorde.inria.fr ([192.93.2.39]) by mail3-smtp-sop.national.inria.fr with ESMTP; 11 Jan 2008 23:55:34 +0100 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id m0BMtWxh028937 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Fri, 11 Jan 2008 23:55:35 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAFaCh0dQW+UCn2dsb2JhbACQDAEBAQEHBAYpmVQ X-IronPort-AV: E=Sophos;i="4.24,273,1196636400"; d="scan'208";a="5957259" Received: from main.gmane.org (HELO ciao.gmane.org) ([80.91.229.2]) by mail2-smtp-roc.national.inria.fr with ESMTP; 11 Jan 2008 23:55:32 +0100 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1JDSmg-000502-BA for caml-list@inria.fr; Fri, 11 Jan 2008 22:55:30 +0000 Received: from ivr94-8-88-162-26-239.fbx.proxad.net ([88.162.26.239]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 11 Jan 2008 22:55:30 +0000 Received: from li by ivr94-8-88-162-26-239.fbx.proxad.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 11 Jan 2008 22:55:30 +0000 X-Injected-Via-Gmane: http://gmane.org/ To: caml-list@inria.fr From: Zheng Li Subject: Re: A confusing module question Date: Sat, 12 Jan 2008 00:38:26 +0100 Message-ID: <87ir202arx.fsf@pps.jussieu.fr> References: <891bd3390801111105xb75df53id4358939e8b2b05c@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: ivr94-8-88-162-26-239.fbx.proxad.net User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.50 (gnu/linux) Cancel-Lock: sha1:dbRYl+qNzJvo8FGSvylCQ+phibM= Sender: news X-Miltered: at concorde with ID 4787F3E4.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; yaron:01 minsky:01 yminsky:01 ocaml:01 model:01 ocaml:01 sig:01 foo:01 semantically:01 sig:01 foo:01 semantically:01 constructors:01 struct:01 compiler:01 "Yaron Minsky" writes: > I've been programming in OCaml for along time, and I still don't have > a really good mental model to understand when some module trick I try > is going to work. How do people think about things like this? OCaml distinguish "type representation" from "type equation", you may want to check the "module type" section of the manual for the definitions. Now consider the example: module type S = sig type exposed_t = {foo : int} type t = exposed_t end We shouldn't expect type exposed_t and type t to be semantically equivelent, as module type S = sig type exposed_t = {foo : int} type t = {foo : int} (* both syntactically and semantically invalid *) end Notice the problem here: the constructors ("foo" here) of type representations are _nominally_ and _exclusive_ bound, which leads to the fact that any type equivelences can only be defined through type equations. Though we can define as many type equivelences (anywhere) as we want, you won't be able to define a single identical type represetation. In other words, type representation is _principle_ and type equation isn't. So we shouldn't expect them to be _exchangable_ just because of type arithmetic. Back to the example, module type S requires a type representation exposed_t and it's type equivelence t. If given module M:S = struct type t = {foo : int} type exposed_t = t end The compiler will fail to find exposed_t has any kind of "representation" and t is not a type equivelence of anyone. You can re-export exposed_t's representation as module M:S = struct type t = {foo: int} type exposed_t = t = {foo: int} end HTH. -- Zheng Li http://www.pps.jussieu.fr/~li