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.4 required=5.0 tests=HTML_MESSAGE,SPF_NEUTRAL autolearn=disabled version=3.1.3 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 1AC32BC6B for ; Fri, 11 Jan 2008 20:05:40 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAE9Mh0fAXQInh2dsb2JhbACCbo0wAQEBCAopkw6GTg X-IronPort-AV: E=Sophos;i="4.24,272,1196636400"; d="scan'208";a="5953352" Received: from concorde.inria.fr ([192.93.2.39]) by mail2-smtp-roc.national.inria.fr with ESMTP; 11 Jan 2008 20:05:39 +0100 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id m0BJ5Y5U023100 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Fri, 11 Jan 2008 20:05:39 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAPFMh0fRVca6kmdsb2JhbACCbo0wAQEBAQcEBCmTD4ZO X-IronPort-AV: E=Sophos;i="4.24,272,1196636400"; d="scan'208";a="21140603" Received: from rv-out-0910.google.com ([209.85.198.186]) by mail4-smtp-sop.national.inria.fr with ESMTP; 11 Jan 2008 20:05:37 +0100 Received: by rv-out-0910.google.com with SMTP id g11so954878rvb.57 for ; Fri, 11 Jan 2008 11:05:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:reply-to:to:subject:mime-version:content-type; bh=FTSgMYiqIZnxh35uHTXABoMaKB0j9r+NLgddBFdcEyE=; b=dv7tFU5GdoyhDP3/+SAjCX7hRMYevBaOboIc0OIdBXyVKXYXJFMmhFgJ8PK4MITYWVPAm3HNBMzdbCy/GrBTXkqpsKDc+X+s8SJRRpCGFcc+IJlSEmrueCqhn5EtikDBsVsqIWCmAMM8xcCD9TfBLTJcx26n3cCmsaVhLl9jFH8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:reply-to:to:subject:mime-version:content-type; b=tobnA7YqQmxskAVsfPBfF/PTCgfHKJYMhiW1wMwYT7hBd6vGNPl+hXpIPYoCDhOGNUUNllFVdRfaXUkTykx04AXbNiXgb77lO2/dWePhMqXOZiGFC7GmyfgZ24IirhbOetYu8Yc65Um/UbkxGuFY0/Rzth3zudmhOQ4Q8tJZ2zA= Received: by 10.140.88.11 with SMTP id l11mr2218876rvb.156.1200078334871; Fri, 11 Jan 2008 11:05:34 -0800 (PST) Received: by 10.141.12.14 with HTTP; Fri, 11 Jan 2008 11:05:34 -0800 (PST) Message-ID: <891bd3390801111105xb75df53id4358939e8b2b05c@mail.gmail.com> Date: Fri, 11 Jan 2008 14:05:34 -0500 From: "Yaron Minsky" Reply-To: yminsky@gmail.com To: "Caml Mailing List" Subject: A confusing module question MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_3000_7160388.1200078334852" X-Miltered: at concorde with ID 4787BDFE.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; yaron:01 minsky:01 yminsky:01 sig:01 sig:01 foo:01 struct:01 foo:01 struct:01 mismatch:01 ocaml:01 model:01 mismatch:01 ocaml:01 model:01 ------=_Part_3000_7160388.1200078334852 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Here's some fairly simple module code that fails unexpectedly. N compiles cleanly, but M has an error, even though they seem like they should both work: module type S = sig type t end module M : sig type exposed_t = { foo : int } include S with type t = exposed_t end = struct type t = { foo : int } type exposed_t = t end module N : sig type exposed_t = { foo : int } include S with type t = exposed_t end = struct type exposed_t = { foo : int } type t = exposed_t end The error is as follows: File "foo.ml", line 8, characters 0-56: Signature mismatch: Modules do not match: sig type t = { foo : int; } type exposed_t = t end is not included in sig type exposed_t = { foo : int; } type t = exposed_t end Type declarations do not match: type exposed_t = t is not included in type exposed_t = { foo : int; } 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? y ------=_Part_3000_7160388.1200078334852 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Here's some fairly simple module code that fails unexpectedly.  N compiles cleanly, but M has an error, even though they seem like they should both work:

module type S = sig type t end

module M :
sig
  type exposed_t = { foo : int }
  include S with type t = exposed_t
end =
struct
  type t = { foo : int }
  type exposed_t = t
end

module N :
sig
  type exposed_t = { foo : int }
  include S with type t = exposed_t
end =
struct
  type exposed_t = { foo : int }
  type t = exposed_t
end

The error is as follows:

File "foo.ml", line 8, characters 0-56:
Signature mismatch:
Modules do not match:
  sig type t = { foo : int; } type exposed_t = t end
is not included in
  sig type exposed_t = { foo : int; } type t = exposed_t end
Type declarations do not match:
  type exposed_t = t
is not included in
  type exposed_t = { foo : int; }

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?

y
------=_Part_3000_7160388.1200078334852--