Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
* A confusing module question
@ 2008-01-11 19:05 Yaron Minsky
  2008-01-11 20:59 ` [Caml-list] " Jeremy Yallop
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Yaron Minsky @ 2008-01-11 19:05 UTC (permalink / raw)
  To: Caml Mailing List

[-- Attachment #1: Type: text/plain, Size: 1045 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 4236 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-01-14  9:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-11 19:05 A confusing module question Yaron Minsky
2008-01-11 20:59 ` [Caml-list] " Jeremy Yallop
2008-01-11 23:38 ` Zheng Li
2008-01-14  9:02 ` [Caml-list] " Keiko Nakata

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox