123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457openOdoc_model.PathsopenOdoc_model.NamesmodulerecResolved:sigtypeparent=[`Moduleofmodule_|`ModuleTypeofmodule_type|`FragmentRoot]andmodule_=[`LocalofIdent.module_|`GpathofPath.Resolved.Module.t|`Substitutedofmodule_|`Substofmodule_type*module_|`Hiddenofmodule_|`Moduleofparent*ModuleName.t|`Canonicalofmodule_*Path.Module.t|`Applyofmodule_*module_|`Aliasofmodule_*Cpath.module_*module_option|`OpaqueModuleofmodule_]andmodule_type=[`LocalofIdent.module_type|`Substitutedofmodule_type|`GpathofPath.Resolved.ModuleType.t|`ModuleTypeofparent*ModuleTypeName.t|`SubstTofmodule_type*module_type|`AliasModuleTypeofmodule_type*module_type|`CanonicalModuleTypeofmodule_type*Path.ModuleType.t|`OpaqueModuleTypeofmodule_type]andtype_=[`LocalofIdent.type_|`GpathofPath.Resolved.Type.t|`Substitutedoftype_|`CanonicalTypeoftype_*Path.Type.t|`CoreTypeofTypeName.t|`Typeofparent*TypeName.t|`Classofparent*TypeName.t|`ClassTypeofparent*TypeName.t]andvalue=[`Valueofparent*ValueName.t|`GpathofPath.Resolved.Value.t]andclass_type=[`LocalofIdent.type_|`Substitutedofclass_type|`GpathofPath.Resolved.ClassType.t|`Classofparent*TypeName.t|`ClassTypeofparent*TypeName.t]end=ResolvedandCpath:sigtypemodule_=[`ResolvedofResolved.module_|`Substitutedofmodule_|`LocalofIdent.module_*bool|`IdentifierofIdentifier.Path.Module.t*bool|`RootofModuleName.t|`Forwardofstring|`Dotofmodule_*ModuleName.t|`ModuleofResolved.parent*ModuleName.t(* Like dot, but typed *)|`Applyofmodule_*module_]andmodule_type=[`ResolvedofResolved.module_type|`Substitutedofmodule_type|`LocalofIdent.module_type*bool|`IdentifierofIdentifier.ModuleType.t*bool|`DotMTofmodule_*ModuleTypeName.t|`ModuleTypeofResolved.parent*ModuleTypeName.t]andtype_=[`ResolvedofResolved.type_|`Substitutedoftype_|`LocalofIdent.type_*bool|`IdentifierofOdoc_model.Paths.Identifier.Path.Type.t*bool|`DotTofmodule_*TypeName.t|`TypeofResolved.parent*TypeName.t|`ClassofResolved.parent*TypeName.t|`ClassTypeofResolved.parent*TypeName.t]andvalue=[`ResolvedofResolved.value|`DotVofmodule_*ValueName.t|`ValueofResolved.parent*ValueName.t|`IdentifierofIdentifier.Value.t*bool]andclass_type=[`ResolvedofResolved.class_type|`Substitutedofclass_type|`LocalofIdent.type_*bool|`IdentifierofOdoc_model.Paths.Identifier.Path.ClassType.t*bool|`DotTofmodule_*TypeName.t|`ClassofResolved.parent*TypeName.t|`ClassTypeofResolved.parent*TypeName.t]end=CpathincludeCpathletrecis_resolved_module_substituted:Resolved.module_->bool=function|`Local_->false|`Substituted_->true|`Gpath_->false|`Subst(_a,_)->false(* is_resolved_module_type_substituted a*)|`Hiddena|`Apply(a,_)|`Alias(a,_,_)|`Canonical(a,_)->is_resolved_module_substituteda|`Module(a,_)->is_resolved_parent_substituteda|`OpaqueModulea->is_resolved_module_substitutedaandis_resolved_parent_substituted=function|`Modulem->is_resolved_module_substitutedm|`ModuleTypem->is_resolved_module_type_substitutedm|`FragmentRoot->falseandis_resolved_module_type_substituted:Resolved.module_type->bool=function|`Local_->false|`Substituted_->true|`Gpath_->false|`ModuleType(a,_)->is_resolved_parent_substituteda|`SubstT_->false|`AliasModuleType(m1,_)->is_resolved_module_type_substitutedm1|`CanonicalModuleType(m,_)|`OpaqueModuleTypem->is_resolved_module_type_substitutedmandis_resolved_type_substituted:Resolved.type_->bool=function|`Local_->false|`CoreType_->false|`Substituted_->true|`Gpath_->false|`CanonicalType(t,_)->is_resolved_type_substitutedt|`Type(a,_)|`Class(a,_)|`ClassType(a,_)->is_resolved_parent_substitutedaandis_resolved_class_type_substituted:Resolved.class_type->bool=function|`Local_->false|`Substituted_->true|`Gpath_->false|`Class(a,_)|`ClassType(a,_)->is_resolved_parent_substitutedaletrecis_module_substituted:module_->bool=function|`Resolveda->is_resolved_module_substituteda|`Identifier_->false|`Local_->false|`Substituted_->true|`Dot(a,_)|`Apply(a,_)->is_module_substituteda|`Forward_->false|`Root_->false|`Module(a,_)->is_resolved_parent_substitutedaletis_module_type_substituted:module_type->bool=function|`Resolveda->is_resolved_module_type_substituteda|`Identifier_->false|`Local_->false|`Substituted_->true|`DotMT(a,_)->is_module_substituteda|`ModuleType(a,_)->is_resolved_parent_substitutedaletis_type_substituted:type_->bool=function|`Resolveda->is_resolved_type_substituteda|`Identifier_->false|`Local_->false|`Substituted_->true|`DotT(a,_)->is_module_substituteda|`Type(a,_)|`Class(a,_)|`ClassType(a,_)->is_resolved_parent_substitutedaletis_class_type_substituted:class_type->bool=function|`Resolveda->is_resolved_class_type_substituteda|`Identifier_->false|`Local_->false|`Substituted_->true|`DotT(a,_)->is_module_substituteda|`Class(a,_)|`ClassType(a,_)->is_resolved_parent_substitutedaletrecis_module_forward:module_->bool=function|`Forward_->true|`Resolved_->false|`Root_->false|`Identifier_->false|`Local_->false|`Substitutedp|`Dot(p,_)|`Apply(p,_)->is_module_forwardp|`Module(_,_)->falseletrecis_module_hidden:module_->bool=function|`Resolvedr->is_resolved_module_hidden~weak_canonical_test:falser|`Substitutedp|`Dot(p,_)|`Apply(p,_)->is_module_hiddenp|`Identifier(_,b)->b|`Local(_,b)->b|`Forward_->false|`Root_->false|`Module(p,_)->is_resolved_parent_hidden~weak_canonical_test:falsepandis_resolved_module_hidden:weak_canonical_test:bool->Resolved.module_->bool=fun~weak_canonical_test->letrecinner=function|`Local_->false|`Gpathp->Odoc_model.Paths.Path.Resolved.Module.is_hidden~weak_canonical_testp|`Hidden_->true|`Canonical(_,`Resolved_)->false|`Canonical(p,_)->(notweak_canonical_test)&&innerp|`Substitutedp->innerp|`Module(p,_)->is_resolved_parent_hidden~weak_canonical_testp|`Subst(p1,p2)->is_resolved_module_type_hiddenp1||innerp2|`Alias(p1,`Resolvedp2,_)->innerp1&&innerp2|`Alias(p1,_p2,_)->innerp1|`Apply(p1,p2)->innerp1||innerp2|`OpaqueModulem->innermininnerandis_resolved_parent_hidden:weak_canonical_test:bool->Resolved.parent->bool=fun~weak_canonical_test->function|`Modulem->is_resolved_module_hidden~weak_canonical_testm|`ModuleTypem->is_resolved_module_type_hiddenm|`FragmentRoot->falseandis_module_type_hidden:module_type->bool=function|`Resolvedr->is_resolved_module_type_hiddenr|`Identifier({iv=`ModuleType(_,t);_},b)->b||ModuleTypeName.is_hiddent|`Local(_,b)->b|`Substitutedp->is_module_type_hiddenp|`DotMT(p,_)->is_module_hiddenp|`ModuleType(p,_)->is_resolved_parent_hidden~weak_canonical_test:falsepandis_resolved_module_type_hidden:Resolved.module_type->bool=function|`Local_->false|`Gpathp->Odoc_model.Paths.Path.Resolved.(is_hidden(p:>t))|`Substitutedp->is_resolved_module_type_hiddenp|`ModuleType(p,_)->is_resolved_parent_hidden~weak_canonical_test:falsep|`SubstT(p1,p2)->is_resolved_module_type_hiddenp1||is_resolved_module_type_hiddenp2|`AliasModuleType(p1,p2)->is_resolved_module_type_hiddenp1||is_resolved_module_type_hiddenp2|`CanonicalModuleType(_,`Resolved_)->false|`CanonicalModuleType(p,_)->is_resolved_module_type_hiddenp|`OpaqueModuleTypem->is_resolved_module_type_substitutedmandis_type_hidden:type_->bool=function|`Resolvedr->is_resolved_type_hiddenr|`Identifier({iv=`Type(_,t);_},b)->b||TypeName.is_hiddent|`Identifier({iv=`ClassType(_,t);_},b)->b||TypeName.is_hiddent|`Identifier({iv=`Class(_,t);_},b)->b||TypeName.is_hiddent|`Local(_,b)->b|`Substitutedp->is_type_hidden(p:>type_)|`DotT(p,_)->is_module_hiddenp|`Type(p,_)|`Class(p,_)|`ClassType(p,_)->is_resolved_parent_hidden~weak_canonical_test:falsepandis_resolved_type_hidden:Resolved.type_->bool=function|`CoreTypen->TypeName.is_hiddenn|`Local_->false|`Gpathp->Odoc_model.Paths.Path.Resolved.(is_hidden(p:>t))|`Substitutedp->is_resolved_type_hiddenp|`CanonicalType(_,`Resolved_)->false|`CanonicalType(p,_)->is_resolved_type_hiddenp|`Type(p,_)|`Class(p,_)|`ClassType(p,_)->is_resolved_parent_hidden~weak_canonical_test:falsepandis_resolved_class_type_hidden:Resolved.class_type->bool=function|`Local_->false|`Gpathp->Odoc_model.Paths.Path.Resolved.(is_hidden(p:>t))|`Substitutedp->is_resolved_class_type_hiddenp|`Class(p,_)|`ClassType(p,_)->is_resolved_parent_hidden~weak_canonical_test:falsepandis_class_type_hidden:class_type->bool=function|`Resolvedr->is_resolved_class_type_hiddenr|`Identifier(_,b)->b|`Local(_,b)->b|`Substitutedp->is_class_type_hiddenp|`DotT(p,_)->is_module_hiddenp|`Class(p,_)|`ClassType(p,_)->is_resolved_parent_hidden~weak_canonical_test:falsepletrecresolved_module_of_resolved_module_reference:Reference.Resolved.Module.t->Resolved.module_=function|`Module(parent,name)->`Module(`Module(resolved_module_of_resolved_signature_referenceparent),name)|`Identifierx->`Gpath(`Identifierx)|`Alias(_m1,_m2)->failwith"gah"|`Hiddens->`Hidden(resolved_module_of_resolved_module_references)andresolved_module_of_resolved_signature_reference:Reference.Resolved.Signature.t->Resolved.module_=function|`Identifier({iv=#Identifier.Module.t_pv;_}asi)->`Gpath(`Identifieri)|(`Alias_|`Module_|`Hidden_)asr'->resolved_module_of_resolved_module_referencer'|`ModuleType(_,n)->failwith("Not a module reference: "^ModuleTypeName.to_stringn)|`AliasModuleType_->failwith"Not a module reference: aliasmoduletype"|`Identifier_->failwith"Not a module reference : identifier"andmodule_of_module_reference:Reference.Module.t->module_=function|`Resolvedr->`Resolved(resolved_module_of_resolved_module_referencer)|`Root(_,_)->failwith"unhandled"|`Dot(((`Resolved(`Identifier{iv=#Identifier.Module.t_pv;_})|`Dot(_,_)|`Module(_,_))asparent),name)->`Dot(module_of_module_referenceparent,ModuleName.make_stdname)|`Module(((`Resolved(`Identifier{iv=#Identifier.Module.t_pv;_})|`Dot(_,_)|`Module(_,_))asparent),name)->`Dot(module_of_module_referenceparent,name)|_->failwith"Not a module reference"letrecunresolve_resolved_module_path:Resolved.module_->module_=function|`Hidden(`Gpath(`Identifierx))->`Identifier(x,true)|`Gpath(`Identifierx)->lethidden=matchx.ivwith|`Module(_,n)->Odoc_model.Names.ModuleName.is_hiddenn|_->falsein`Identifier(x,hidden)|`Gpath_asx->`Resolvedx|`Hidden(`Localx)->`Local(x,true)|`Localx->`Local(x,false)|`Substitutedx->unresolve_resolved_module_pathx|`Subst(_,x)->unresolve_resolved_module_pathx|`Hiddenx->unresolve_resolved_module_pathx(* should assert false here *)|`Module(p,m)->`Dot(unresolve_resolved_parent_pathp,m)|`Canonical(m,_)->unresolve_resolved_module_pathm|`Apply(m,a)->`Apply(unresolve_resolved_module_pathm,unresolve_resolved_module_patha)|`Alias(_,`Resolvedm,_)->unresolve_resolved_module_pathm|`Alias(_,m,_)->m|`OpaqueModulem->unresolve_resolved_module_pathmandunresolve_module_path:module_->module_=function|`Resolvedx->unresolve_resolved_module_pathx|`Substitutedx->unresolve_module_pathx|`Local(_,_)asx->x|`Identifier_asx->x|`Root_asx->x|`Forward_asx->x|`Dot(p,x)->`Dot(unresolve_module_pathp,x)|`Module(p,x)->`Dot(unresolve_resolved_parent_pathp,x)|`Apply(x,y)->`Apply(unresolve_module_pathx,unresolve_module_pathy)andunresolve_resolved_module_type_path:Resolved.module_type->module_type=function|(`Local_|`Gpath_)asp->`Resolvedp|`Substitutedx->unresolve_resolved_module_type_pathx|`ModuleType(p,n)->`DotMT(unresolve_resolved_parent_pathp,n)|`SubstT(_,m)->unresolve_resolved_module_type_pathm|`AliasModuleType(_,m2)->unresolve_resolved_module_type_pathm2|`CanonicalModuleType(p,_)->unresolve_resolved_module_type_pathp|`OpaqueModuleTypem->unresolve_resolved_module_type_pathmandunresolve_resolved_parent_path:Resolved.parent->module_=function|`Modulem->unresolve_resolved_module_pathm|`FragmentRoot|`ModuleType_->assertfalseandunresolve_resolved_type_path:Resolved.type_->type_=function|(`Gpath_|`Local_|`CoreType_)asp->`Resolvedp|`Substitutedx->unresolve_resolved_type_pathx|`CanonicalType(t1,_)->unresolve_resolved_type_patht1|`Type(p,n)->`DotT(unresolve_resolved_parent_pathp,n)|`Class(p,n)->`DotT(unresolve_resolved_parent_pathp,n)|`ClassType(p,n)->`DotT(unresolve_resolved_parent_pathp,n)andunresolve_resolved_class_type_path:Resolved.class_type->class_type=function|(`Local_|`Gpath_)asp->`Resolvedp|`Substitutedx->unresolve_resolved_class_type_pathx|`Class(p,n)->`DotT(unresolve_resolved_parent_pathp,n)|`ClassType(p,n)->`DotT(unresolve_resolved_parent_pathp,n)andunresolve_module_type_path:module_type->module_type=function|`Resolvedm->unresolve_resolved_module_type_pathm|y->yandunresolve_type_path:type_->type_=function|`Resolvedm->(unresolve_resolved_type_pathm:>type_)|y->yandunresolve_class_type_path:class_type->class_type=function|`Resolvedm->unresolve_resolved_class_type_pathm|y->y(*
These are left here for later. The idea is to alter a resolved path
such that all the identifiers in it are turned into fully-qualified
resolved paths. This is intended to be used to turn the 'original
path' of `module type of` expressions that was resolved in the
original context into a path that is valid in _all_ contexts.
let rec original_path_cpath : module_ -> module_ option = function
| `Resolved p ->
original_path_cpath (unresolve_resolved_module_path p)
| `Root name -> Some (`Root name)
| `Forward _ -> None
| `Dot (p, s) -> (
match original_path_cpath p with
| Some p -> Some (`Dot (p, s))
| None -> None)
| `Apply (p1, p2) -> (
match (original_path_cpath p1, original_path_cpath p2) with
| Some p1', Some p2' -> Some (`Apply (p1', p2'))
| _ -> None)
| `Identifier (i, _) -> (
match original_path_module_identifier i with
| Some i -> Some (`Resolved i)
| None -> None)
| `Substituted p -> original_path_cpath p
| `Local _ ->
None
| `Module _ ->
None
and original_path_module_identifier :
Odoc_model.Paths.Identifier.Path.Module.t -> Resolved.module_ option =
fun id ->
match id.iv with
| `Module (sg, name) -> (
match original_path_parent_identifier sg with
| Some sg' -> Some (`Module (sg', name))
| None -> None)
| `Root _ -> Some (`Gpath (`Identifier id))
| _ ->
None
and original_path_parent_identifier :
Odoc_model.Paths.Identifier.Signature.t -> Resolved.parent option =
fun id ->
match id with
| { iv = `Module _ | `Root _ | `Parameter _ | `Result _; _ } as mid -> (
match original_path_module_identifier mid with
| Some m -> Some (`Module m)
| None -> None)
| { iv = `ModuleType _; _ } as mtid -> (
match original_path_module_type_identifier mtid with
| Some m -> Some (`ModuleType m)
| None -> None)
and original_path_module_type_identifier :
Odoc_model.Paths.Identifier.ModuleType.t -> Resolved.module_type option =
fun id ->
match id.iv with
| `ModuleType (sg, name) -> (
match original_path_parent_identifier sg with
| Some sg' -> Some (`ModuleType (sg', name))
| None -> None)
*)