Module types / aliases

consider:

module type list = module type of List (* module expression iis an alias *)
module type list2 = module type of Stdlib__List (* mod-exp is not an alias *)
module M=Stdlib__List           (* but type of module expression here IS alias! *)

the type declarations lead me to believe a module expression carries a type
independent of its context but the declaration of M, the creation of an alias, suggests
otherwise.
why is it that the module expression Stdlib__List in this position doesn’t remain a non-alias?

It’s not clear what behaviour you find unexpected.
In your code, you have two module types (which are computed by expanding any aliases) and a module alias.
I expect that module type of M will give you the same result as module type of List.
Does that answer your question ?

the module expressions of the two module type declarations are List and Stdlib__List respectively and their module types are recorded (in the typed-tree) respectively as Mty_alias and Mty_ident - alias and non-alias.
but with module M = Stdlib__List the module expression Stdlib__List is carrying Mty_alias (in field mod_type).
my expectation, based on the non-alias status of the 2nd module type declaration,
is for Mty_ident not Mty_alias.
as [module M=Stdlib__List] is the introduction of an alias it would be no surprise
to see the md_type of the declaration recorded this way but the module expression is a separate entity and not to be effected by its context, or so I thought.

is unification forcing the Mty_alias of the module expression even though Stdlib__List is obviously not an alias?
my interest is in having an unambiguous indication of alias/non-alias status.

The distinction between alias and not alias is not meaningful in expressions; each alias also has a regular module type, and even non-alias modules can be seen as aliases to themselves conceptually, so the type you’ll get on the expression might be either of those depending on which one is more useful in the context. You should look inside the environments stored in the typedtree if you want a reliable way to know whether a given module was defined as an alias or not.

that’s great. thanks!