123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120(* Note for future improvement (suggested by @lpw25):
You can actually do something even more interesting with that case for strengthening.
If you have:
[module type S = sig type t end]
and you want to strengthen [S] with the module path [M] then you can produce:
[S with type t = M.t]
The compiler doesn't do this because it doesn't actually have a representation for `with` in its type algebra
(`with` is always just expanded away right after parsing). But since we do have a representation for it,
this is probably the best thing to produce in this case.
*)openComponentopenDelayedletrecsignature:Cpath.module_->?canonical:Odoc_model.Paths.Path.Module.t->Signature.t->Signature.t=funprefix?canonicalsg->letsg',strengthened_modules=sig_itemsprefix?canonicalsginletsubsts=List.fold_left(funsmid->Subst.path_invalidate_module(mid:>Ident.path_module)s)Subst.identitystrengthened_modulesinSubst.signaturesubstssg'andsig_itemsprefix?canonicalsg=letopenSignatureinletitems,ids=List.fold_left(fun(items,s)item->matchitemwith|Module(id,r,m)->letname=Ident.Name.module_idinletcanonical=matchcanonicalwith|Somep->Some(`Dot(p,name))|None->Noneinletm'()=module_?canonical(`Dot(prefix,name))(getm)in(Module(id,r,putm')::items,id::s)|ModuleType(id,mt)->(ModuleType(id,put(fun()->module_type(`Dot(prefix,Ident.Name.module_typeid))(getmt)))::items,s)|Type(id,r,t)->(Type(id,r,put(fun()->type_decl(`Dot(prefix,Ident.Name.type_id))(gett)))::items,s)|Includei->leti',strengthened=include_prefixiin(Includei'::items,strengthened@s)|Exception_|TypExt_|Value_|Class_|ClassType_|ModuleSubstitution_|TypeSubstitution_|ModuleTypeSubstitution_|Comment_|Open_->(item::items,s))([],[])sg.itemsin({sgwithitems=List.revitems},ids)andmodule_:?canonical:Odoc_model.Paths.Path.Module.t->Cpath.module_->Component.Module.t->Component.Module.t=fun?canonicalprefixm->{mwithcanonical;type_=Alias(prefix,None)}(* nuke the expansion as this could otherwise lead to inconsistencies - e.g. 'AlreadyASig' *)andmodule_type:Cpath.module_type->Component.ModuleType.t->Component.ModuleType.t=funprefixm->letexpr=Some(ModuleType.Path{p_path=prefix;p_expansion=None})in{mwithexpr}andtype_decl:Cpath.type_->TypeDecl.t->TypeDecl.t=funpatht->letequation=lete=t.TypeDecl.equationinletopenTypeDecl.Equationinletconstr_params=List.map(fun{Odoc_model.Lang.TypeDecl.desc;_}->matchdescwith|Odoc_model.Lang.TypeDecl.Varx->TypeExpr.Varx|Any->Any)e.paramsinletmanifest=matche.manifestwith|None->Some(TypeExpr.Constr(path,constr_params))|_->e.manifestin{params=e.params;private_=e.private_;manifest;constraints=e.constraints;}in{twithequation}andinclude_:Cpath.module_->Include.t->Include.t*Ident.module_list=funpathi->letexpansion_,strengthened=sig_itemspathi.expansion_in({iwithexpansion_;strengthened=Somepath},strengthened)