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