12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253(*
* Copyright (c) 2014 Leo White <lpw25@cl.cam.ac.uk>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*)moduleOcaml_ident=IdentmoduleOcaml_env=EnvopenNamesmoduleIdentifier=structmoduleId=Paths_types.Identifiertypet=Id.anyletrecname_aux:t->string=funx->matchxwith|`Root(_,name)->ModuleName.to_stringname|`Page(_,name)->PageName.to_stringname|`LeafPage(_,name)->PageName.to_stringname|`Module(_,name)->ModuleName.to_stringname|`Parameter(_,name)->ModuleName.to_stringname|`Resultx->name_aux(x:>t)|`ModuleType(_,name)->ModuleTypeName.to_stringname|`Type(_,name)->TypeName.to_stringname|`Constructor(_,name)->ConstructorName.to_stringname|`Field(_,name)->FieldName.to_stringname|`UnboxedField(_,name)->UnboxedFieldName.to_stringname|`Extension(_,name)->ExtensionName.to_stringname|`ExtensionDecl(_,_,name)->ExtensionName.to_stringname|`Exception(_,name)->ExceptionName.to_stringname|`Value(_,name)->ValueName.to_stringname|`Class(_,name)->TypeName.to_stringname|`ClassType(_,name)->TypeName.to_stringname|`Method(_,name)->MethodName.to_stringname|`InstanceVariable(_,name)->InstanceVariableName.to_stringname|`Label(_,name)->LabelName.to_stringname|`SourcePage(_,name)->name|`SourceLocation(x,anchor)->name_aux(x:>t)^"#"^DefName.to_stringanchor|`SourceLocationModx->name_aux(x:>t)|`SourceLocationInternal(x,anchor)->name_aux(x:>t)^"#"^LocalName.to_stringanchor|`AssetFile(_,name)->AssetName.to_stringnameletrecis_hidden:t->bool=funx->matchxwith|`Root(_,name)->ModuleName.is_hiddenname|`Page(_,_)->false|`LeafPage(_,_)->false|`Module(_,name)->ModuleName.is_hiddenname|`Parameter(_,name)->ModuleName.is_hiddenname|`Resultx->is_hidden(x:>t)|`ModuleType(_,name)->ModuleTypeName.is_hiddenname|`Type(_,name)->TypeName.is_hiddenname|`Constructor(parent,_)->is_hidden(parent:>t)|`Field(parent,_)->is_hidden(parent:>t)|`UnboxedField(parent,_)->is_hidden(parent:>t)|`Extension(parent,_)->is_hidden(parent:>t)|`ExtensionDecl(parent,_,_)->is_hidden(parent:>t)|`Exception(parent,_)->is_hidden(parent:>t)|`Value(_,name)->ValueName.is_hiddenname|`Class(_,name)->TypeName.is_hiddenname|`ClassType(_,name)->TypeName.is_hiddenname|`Method(parent,_)->is_hidden(parent:>t)|`InstanceVariable(parent,_)->is_hidden(parent:>t)|`Label(parent,_)->is_hidden(parent:>t)|`SourceLocationMod_|`SourceLocation_|`SourcePage_|`SourceLocationInternal_|`AssetFile_->falseletname:[<t]->string=funn->name_aux(n:>t)letrecfull_name_aux:t->stringlist=funx->matchxwith|`Root(_,name)->[ModuleName.to_stringname]|`Page(None,name)->[PageName.to_stringname]|`Page(Someparent,name)->PageName.to_stringname::full_name_aux(parent:>t)|`LeafPage(None,name)->[PageName.to_stringname]|`LeafPage(Someparent,name)->PageName.to_stringname::full_name_aux(parent:>t)|`Module(parent,name)->ModuleName.to_stringname::full_name_aux(parent:>t)|`Parameter(parent,name)->ModuleName.to_stringname::full_name_aux(parent:>t)|`Resultx->full_name_aux(x:>t)|`ModuleType(parent,name)->ModuleTypeName.to_stringname::full_name_aux(parent:>t)|`Type(parent,name)->TypeName.to_stringname::full_name_aux(parent:>t)|`Constructor(parent,name)->ConstructorName.to_stringname::full_name_aux(parent:>t)|`Field(parent,name)->FieldName.to_stringname::full_name_aux(parent:>t)|`UnboxedField(parent,name)->UnboxedFieldName.to_stringname::full_name_aux(parent:>t)|`Extension(parent,name)->ExtensionName.to_stringname::full_name_aux(parent:>t)|`ExtensionDecl(parent,_,name)->ExtensionName.to_stringname::full_name_aux(parent:>t)|`Exception(parent,name)->ExceptionName.to_stringname::full_name_aux(parent:>t)|`Value(parent,name)->ValueName.to_stringname::full_name_aux(parent:>t)|`Class(parent,name)->TypeName.to_stringname::full_name_aux(parent:>t)|`ClassType(parent,name)->TypeName.to_stringname::full_name_aux(parent:>t)|`Method(parent,name)->MethodName.to_stringname::full_name_aux(parent:>t)|`InstanceVariable(parent,name)->InstanceVariableName.to_stringname::full_name_aux(parent:>t)|`Label(parent,name)->LabelName.to_stringname::full_name_aux(parent:>t)|`SourceLocation(parent,name)->DefName.to_stringname::full_name_aux(parent:>t)|`SourceLocationInternal(parent,name)->LocalName.to_stringname::full_name_aux(parent:>t)|`SourceLocationModname->full_name_aux(name:>t)|`SourcePage(parent,name)->name::full_name_aux(parent:>t)|`AssetFile(parent,name)->AssetName.to_stringname::full_name_aux(parent:>t)letfullname:[<t]->stringlist=funn->List.rev@@full_name_aux(n:>t)letis_hidden:[<t]->bool=funn->is_hidden(n:>t)letreclabel_parent_aux=letopenIdinfun(n:non_src)->matchnwith|`Resulti->label_parent_aux(i:>non_src)|`Root_asp->(p:>label_parent)|`Page_asp->(p:>label_parent)|`LeafPage_asp->(p:>label_parent)|`Module(p,_)|`ModuleType(p,_)|`Parameter(p,_)|`Class(p,_)|`ClassType(p,_)|`Type(p,_)|`Extension(p,_)|`ExtensionDecl(p,_,_)|`Exception(p,_)|`Value(p,_)->(p:signature:>label_parent)|`Label(p,_)->p|`Method(p,_)|`InstanceVariable(p,_)->(p:class_signature:>label_parent)|`Constructor(p,_)->(p:datatype:>label_parent)|`Field(p,_)->(p:field_parent:>label_parent)|`UnboxedField(p,_)->(p:unboxed_field_parent:>label_parent)letlabel_parentn=label_parent_aux(n:>Id.non_src)(* An identifier is now just plain data, so structural equality is the right
notion. *)letequalxy=x==y||x=y(* Deliberately not [Hashtbl.hash], which is [hash_param 10 100]. Hashing is a
breadth-first walk that stops after [count] meaningful nodes (ints,
strings) or [limit] enqueued ones, and each identifier level costs several
of each, so a budget of 10 is exhausted a few levels down and never reaches
the root.
256/256 is the most reach obtainable: the runtime clamps [limit] to its
fixed-size traversal queue (HASH_QUEUE_SIZE, runtime/hash.c), so larger
values are silently ignored and cannot help. *)lethashx=Hashtbl.hash_param256256x(* Left polymorphic on purpose: every sub-module below reuses this as its
own [compare], each at a narrower identifier type. *)letcompare=Stdlib.comparetypeany=tmoduletypeIdSig=sigtypetvalequal:t->t->boolvalhash:t->intvalcompare:t->t->intendmoduleAny=structtypet=anyletequal=equallethash=hashletcompare=compareendmoduleSignature=structtypet=Id.signatureletequal=equallethash=hashletcompare=compareendmoduleClassSignature=structtypet=Id.class_signatureletequal=equallethash=hashletcompare=compareendmoduleDataType=structtypet=Id.datatypeendmoduleFieldParent=structtypet=Paths_types.Identifier.field_parentendmoduleUnboxedFieldParent=structtypet=Paths_types.Identifier.unboxed_field_parentendmoduleLabelParent=structtypet=Id.label_parentletequal=equallethash=hashletcompare=compareendmoduleRootModule=structtypet=Id.root_moduleletequal=equallethash=hashletcompare=compareendmoduleModule=structtypet=Id.module_letequal=equallethash=hashletcompare=compareendmoduleFunctorParameter=structtypet=Id.functor_parameterletequal=equallethash=hashletcompare=compareletfunctor_arg_pos(`Parameter(p,_))=letrecinner_sig=function|`Resultp->1+inner_sigp|`Module_|`ModuleType_|`Root_|`Parameter_->1ininner_sigpendmoduleFunctorResult=structtypet=Id.functor_resultendmoduleModuleType=structtypet=Id.module_typeletequal=equallethash=hashletcompare=compareendmoduleType=structtypet=Id.type_letequal=equallethash=hashletcompare=compareendmoduleConstructor=structtypet=Id.constructorendmoduleField=structtypet=Id.fieldendmoduleUnboxedField=structtypet=Id.unboxed_fieldendmoduleExtension=structtypet=Id.extensionendmoduleExtensionDecl=structtypet=Paths_types.Identifier.extension_declletequal=equallethash=hashletcompare=compareendmoduleException=structtypet=Id.exception_endmoduleValue=structtypet=Id.valueendmoduleClass=structtypet=Id.class_letequal=equallethash=hashletcompare=compareendmoduleClassType=structtypet=Id.class_typeletequal=equallethash=hashletcompare=compareendmoduleMethod=structtypet=Id.method_endmoduleInstanceVariable=structtypet=Id.instance_variableendmoduleLabel=structtypet=Paths_types.Identifier.labelletequal=equallethash=hashletcompare=compareendmodulePage=structtypet=Id.pageendmoduleLeafPage=structtypet=Id.leaf_pageletequal=equallethash=hashendmoduleContainerPage=structtypet=Id.container_pageletequal=equallethash=hashendmoduleNonSrc=structtypet=Paths_types.Identifier.non_srcletequal=equallethash=hashendmoduleSourcePage=structtypet=Id.source_pageletequal=equallethash=hashendmoduleSourceLocation=structtypet=Paths_types.Identifier.source_locationendmoduleAssetFile=structtypet=Id.asset_fileendmoduleOdocId=structtypet=Id.odoc_idendmodulePath=structmoduleModule=structtypet=Id.path_moduleletequal=equallethash=hashletcompare=compareendmoduleModuleType=structtypet=Id.path_module_typeletequal=equallethash=hashletcompare=compareendmoduleType=structtypet=Id.path_typeletequal=equallethash=hashletcompare=compareendmoduleValue=structtypet=Id.path_valueletequal=equallethash=hashletcompare=compareendmoduleClassType=structtypet=Id.path_class_typeletequal=equallethash=hashletcompare=compareendtypet=Id.path_anyendmoduleMaps=structmoduleAny=Map.Make(Any)moduleFunctorParameter=Map.Make(FunctorParameter)moduleModule=Map.Make(Module)moduleModuleType=Map.Make(ModuleType)moduleType=Map.Make(Type)moduleClass=Map.Make(Class)moduleClassType=Map.Make(ClassType)moduleLabel=Map.Make(Label)modulePath=structmoduleModule=Map.Make(Path.Module)moduleModuleType=Map.Make(Path.ModuleType)moduleType=Map.Make(Path.Type)moduleClassType=Map.Make(Path.ClassType)endendmoduleMk=structletmkfx=fxletpage:ContainerPage.toption*PageName.t->[>`PageofContainerPage.toption*PageName.t]=mk(fun(p,n)->`Page(p,n))letleaf_page:ContainerPage.toption*PageName.t->[>`LeafPageofContainerPage.toption*PageName.t]=mk(fun(p,n)->`LeafPage(p,n))letasset_file:Page.t*AssetName.t->AssetFile.t=mk(fun(p,n)->`AssetFile(p,n))letsource_page(container_page,name)=mk(fun(p,rp)->`SourcePage(p,rp))(container_page,name)letroot:ContainerPage.toption*ModuleName.t->[>`RootofContainerPage.toption*ModuleName.t]=mk(fun(p,n)->`Root(p,n))letimplementation=mk(funs->`Implementation(ModuleName.make_stds))letmodule_:Signature.t*ModuleName.t->[>`ModuleofSignature.t*ModuleName.t]=mk(fun(p,n)->`Module(p,n))letparameter:Signature.t*ModuleName.t->[>`ParameterofSignature.t*ModuleName.t]=mk(fun(p,n)->`Parameter(p,n))letresult:Signature.t->[>`ResultofSignature.t]=funs->mk(funs->`Results)sletmodule_type:Signature.t*ModuleTypeName.t->[>`ModuleTypeofSignature.t*ModuleTypeName.t]=mk(fun(p,n)->`ModuleType(p,n))letclass_:Signature.t*TypeName.t->[>`ClassofSignature.t*TypeName.t]=mk(fun(p,n)->`Class(p,n))letclass_type:Signature.t*TypeName.t->[>`ClassTypeofSignature.t*TypeName.t]=mk(fun(p,n)->`ClassType(p,n))lettype_:Signature.t*TypeName.t->[>`TypeofSignature.t*TypeName.t]=mk(fun(p,n)->`Type(p,n))letcore_type=mk(funs->`CoreType(TypeName.make_stds))letconstructor:DataType.t*ConstructorName.t->[>`ConstructorofDataType.t*ConstructorName.t]=mk(fun(p,n)->`Constructor(p,n))letfield:FieldParent.t*FieldName.t->[>`FieldofFieldParent.t*FieldName.t]=mk(fun(p,n)->`Field(p,n))letunboxed_field:UnboxedFieldParent.t*UnboxedFieldName.t->[>`UnboxedFieldofUnboxedFieldParent.t*UnboxedFieldName.t]=mk(fun(p,n)->`UnboxedField(p,n))letextension:Signature.t*ExtensionName.t->[>`ExtensionofSignature.t*ExtensionName.t]=mk(fun(p,n)->`Extension(p,n))letextension_decl:Signature.t*(ExtensionName.t*ExtensionName.t)->[>`ExtensionDeclofSignature.t*ExtensionName.t*ExtensionName.t]=mk(fun(p,(n,m))->`ExtensionDecl(p,n,m))letexception_:Signature.t*ExceptionName.t->[>`ExceptionofSignature.t*ExceptionName.t]=mk(fun(p,n)->`Exception(p,n))letvalue:Signature.t*ValueName.t->[>`ValueofSignature.t*ValueName.t]=mk(fun(p,n)->`Value(p,n))letmethod_:ClassSignature.t*MethodName.t->[>`MethodofClassSignature.t*MethodName.t]=mk(fun(p,n)->`Method(p,n))letinstance_variable:ClassSignature.t*InstanceVariableName.t->[>`InstanceVariableofClassSignature.t*InstanceVariableName.t]=mk(fun(p,n)->`InstanceVariable(p,n))letlabel:LabelParent.t*LabelName.t->[>`LabelofLabelParent.t*LabelName.t]=mk(fun(p,n)->`Label(p,n))letsource_location:SourcePage.t*DefName.t->[>`SourceLocationofSourcePage.t*DefName.t]=mk(fun(p,n)->`SourceLocation(p,n))letsource_location_mod:SourcePage.t->[>`SourceLocationModofSourcePage.t]=funs->mk(funs->`SourceLocationMods)sletsource_location_int:SourcePage.t*LocalName.t->[>`SourceLocationInternalofSourcePage.t*LocalName.t]=mk(fun(p,n)->`SourceLocationInternal(p,n))end(* Counter for generating unique synthetic parents for include expressions.
Items inside an include's module type expression need a different parent
to avoid identifier conflicts with items in the enclosing signature. *)letinclude_parent_counter=ref0(* Create a synthetic parent identifier for items inside an include's module
type expression. Uses a lowercase module name (illegal in normal OCaml)
to ensure no clashes with real identifiers. *)letfresh_include_parent(parent:Signature.t):Signature.t=incrinclude_parent_counter;letname=Printf.sprintf"include%d_"!include_parent_counterin(Mk.module_(parent,ModuleName.make_stdname):>Signature.t)letmodule_arg_parent_counter=ref0(* Create a synthetic parent identifier for module arguments, which can't have
unique identifier, as they can be introduced multiple times with the same
name in a single type expression . *)letfresh_module_arg_parent():Signature.t=incrmodule_arg_parent_counter;letname=Printf.sprintf"module_arg_%d_"!module_arg_parent_counterin(Mk.root(None,ModuleName.hidden_of_stringname):>Signature.t)moduleHashtbl=structmoduleAny=Hashtbl.Make(Any)moduleContainerPage=Hashtbl.Make(ContainerPage)moduleLeafPage=Hashtbl.Make(LeafPage)moduleRootModule=Hashtbl.Make(RootModule)moduleSourcePage=Hashtbl.Make(SourcePage)endendmodulePath=structtypet=Paths_types.Path.anyletrecis_resolved_hidden:weak_canonical_test:bool->Paths_types.Resolved_path.any->bool=fun~weak_canonical_testx->letopenPaths_types.Resolved_pathinletrecinner:Paths_types.Resolved_path.any->bool=function|`Identifier(`ModuleType(_,m))whenNames.ModuleTypeName.is_hiddenm->true|`Identifier(`Type(_,t))whenNames.TypeName.is_hiddent->true|`Identifier(`Module(_,m))whenNames.ModuleName.is_hiddenm->true|`Identifierid->Identifier.is_hiddenid|`Canonical(_,`Resolved_)->false|`Canonical(x,_)->(notweak_canonical_test)&&inner(x:module_:>any)|`Hidden_->true|`Subst(p1,p2)->inner(p1:module_type:>any)||inner(p2:module_:>any)|`Module(p,_)->inner(p:module_:>any)|`Apply(p,_)->inner(p:module_:>any)|`ModuleType(_,m)whenNames.ModuleTypeName.is_hiddenm->true|`ModuleType(p,_)->inner(p:module_:>any)|`Type(_,t)whenNames.TypeName.is_hiddent->true|`CoreTypet->Names.TypeName.is_hiddent|`Type(p,_)->inner(p:module_:>any)|`Value(_,t)whenNames.ValueName.is_hiddent->true|`Value(p,_)->inner(p:module_:>any)|`Class(p,_)->inner(p:module_:>any)|`ClassType(p,_)->inner(p:module_:>any)|`Alias(dest,`Resolvedsrc)->inner(dest:module_:>any)&&inner(src:module_:>any)|`Alias(dest,src)->inner(dest:module_:>any)&&is_path_hidden(src:>Paths_types.Path.any)|`AliasModuleType(p1,p2)->inner(p1:module_type:>any)&&inner(p2:module_type:>any)|`SubstT(p1,p2)->inner(p1:>any)||inner(p2:>any)|`Substitutedm->inner(m:>any)|`SubstitutedMTm->inner(m:>any)|`SubstitutedTm->inner(m:>any)|`SubstitutedCTm->inner(m:>any)|`CanonicalModuleType(_,`Resolved_)->false|`CanonicalModuleType(x,_)->inner(x:module_type:>any)|`CanonicalType(_,`Resolved_)->false|`CanonicalType(x,_)->inner(x:type_:>any)|`OpaqueModulem->inner(m:>any)|`OpaqueModuleTypemt->inner(mt:>any)|`Unboxmt->inner(mt:>any)ininnerxandis_path_hidden:Paths_types.Path.any->bool=letopenPaths_types.Pathinfunction|`Resolvedr->is_resolved_hidden~weak_canonical_test:falser|`Identifier(id,hidden)->hidden||Identifier.is_hiddenid|`Substitutedr->is_path_hidden(r:>any)|`SubstitutedMTr->is_path_hidden(r:>any)|`SubstitutedTr->is_path_hidden(r:>any)|`SubstitutedCTr->is_path_hidden(r:>any)|`Unboxr->is_path_hidden(r:>any)|`Roots->ModuleName.is_hiddens|`Dot(p,n)->ModuleName.is_hiddenn||is_path_hidden(p:module_:>any)|`DotMT(p,n)->ModuleTypeName.is_hiddenn||is_path_hidden(p:module_:>any)|`DotT(p,n)->TypeName.is_hiddenn||is_path_hidden(p:module_:>any)|`DotV(p,n)->ValueName.is_hiddenn||is_path_hidden(p:module_:>any)|`Apply(p1,p2)->is_path_hidden(p1:module_:>any)||is_path_hidden(p2:module_:>any)moduleResolved=structtypet=Paths_types.Resolved_path.anyletrecparent_module_type_identifier:Paths_types.Resolved_path.module_type->Identifier.ModuleType.toption=function|`Identifierid->Some(id:Identifier.ModuleType.t)|`ModuleType(m,n)->(matchparent_module_identifiermwith|None->None|Somep->Some(Identifier.Mk.module_type(p,n)))|`SubstT(m,_n)->parent_module_type_identifierm|`CanonicalModuleType(_,`Resolvedp)->parent_module_type_identifierp|`CanonicalModuleType(p,_)->parent_module_type_identifierp|`OpaqueModuleTypemt->parent_module_type_identifiermt|`SubstitutedMTm->parent_module_type_identifierm|`AliasModuleType(sub,orig)->ifis_resolved_hidden~weak_canonical_test:false(sub:>t)thenparent_module_type_identifierorigelseparent_module_type_identifiersubandparent_module_identifier:Paths_types.Resolved_path.module_->Identifier.Signature.toption=function|`Identifierid->Some(id:Identifier.Path.Module.t:>Identifier.Signature.t)|`Subst(sub,_)->(parent_module_type_identifiersub:>Identifier.Signature.toption)|`Hidden_->None|`Module(m,n)->(matchparent_module_identifiermwith|None->None|Somep->Some(Identifier.Mk.module_(p,n)))|`Canonical(_,`Resolvedp)->parent_module_identifierp|`Canonical(p,_)->parent_module_identifierp|`Apply(m,_)->parent_module_identifierm|`Alias(dest,`Resolvedsrc)->ifis_resolved_hidden~weak_canonical_test:false(dest:>t)thenparent_module_identifiersrcelseparent_module_identifierdest|`Alias(dest,_src)->parent_module_identifierdest|`Substitutedm->parent_module_identifierm|`OpaqueModulem->parent_module_identifiermmoduleModule=structtypet=Paths_types.Resolved_path.module_letis_hiddenm=is_resolved_hidden(m:t:>Paths_types.Resolved_path.any)(* [Identifier.equal]/[Identifier.hash] are polymorphic; the same policy
works for resolved-path spines. *)letequal=Identifier.equallethash=Identifier.hashmoduleHashtbl=Hashtbl.Make(structtypenonrect=tletequal=equallethash=hashend)endmoduleModuleType=structtypet=Paths_types.Resolved_path.module_typeletidentifier:t->Identifier.ModuleType.toption=parent_module_type_identifierendmoduleType=structtypet=Paths_types.Resolved_path.type_endmoduleValue=structtypet=Paths_types.Resolved_path.valueendmoduleClassType=structtypet=Paths_types.Resolved_path.class_typeendletrecidentifier:t->Identifier.toption=letparentpf=matchparent_module_identifierpwith|None->None|Someid->Some(fid:>Identifier.t)infunction|`Identifierid->Someid|`CoreType_->None|`Subst(sub,_)->identifier(sub:>t)|`Hidden_p->None|`Module(m,n)->parentm(funp->Identifier.Mk.module_(p,n))|`Canonical(_,`Resolvedp)->identifier(p:>t)|`Canonical(p,_)->identifier(p:>t)|`Apply(m,_)->identifier(m:>t)|`Type(m,n)->parentm(funp->Identifier.Mk.type_(p,n))|`Value(m,n)->parentm(funp->Identifier.Mk.value(p,n))|`ModuleType(m,n)->parentm(funp->Identifier.Mk.module_type(p,n))|`Class(m,n)->parentm(funp->Identifier.Mk.class_(p,n))|`ClassType(m,n)->parentm(funp->Identifier.Mk.class_type(p,n))|`Alias(dest,`Resolvedsrc)->ifis_resolved_hidden~weak_canonical_test:false(dest:>t)thenidentifier(src:>t)elseidentifier(dest:>t)|`Alias(dest,_src)->identifier(dest:>t)|`AliasModuleType(sub,orig)->ifis_resolved_hidden~weak_canonical_test:false(sub:>t)thenidentifier(orig:>t)elseidentifier(sub:>t)|`SubstT(p,_)->identifier(p:>t)|`CanonicalModuleType(_,`Resolvedp)->identifier(p:>t)|`CanonicalModuleType(p,_)->identifier(p:>t)|`CanonicalType(_,`Resolvedp)->identifier(p:>t)|`CanonicalType(p,_)->identifier(p:>t)|`OpaqueModulem->identifier(m:>t)|`OpaqueModuleTypemt->identifier(mt:>t)|`Substitutedm->identifier(m:>t)|`SubstitutedMTm->identifier(m:>t)|`SubstitutedCTm->identifier(m:>t)|`SubstitutedTm->identifier(m:>t)|`Unboxm->identifier(m:>t)letis_hiddenr=is_resolved_hidden~weak_canonical_test:falserendmoduleModule=structtypet=Paths_types.Path.module_endmoduleModuleType=structtypet=Paths_types.Path.module_typeendmoduleType=structtypet=Paths_types.Path.type_endmoduleValue=structtypet=Paths_types.Path.valueendmoduleClassType=structtypet=Paths_types.Path.class_typeendletis_hidden=is_path_hiddenendmoduleFragment=structmoduleResolved=structtypet=Paths_types.Resolved_fragment.anytyperoot=Paths_types.Resolved_fragment.rootmoduleSignature=structtypet=Paths_types.Resolved_fragment.signatureletrecsgidentifier:t->Identifier.Signature.toption=function|`Root(`ModuleTypei)->(Path.Resolved.parent_module_type_identifieri:>Identifier.Signature.toption)|`Root(`Modulei)->Path.Resolved.parent_module_identifieri|`Subst(s,_)->(Path.Resolved.parent_module_type_identifiers:>Identifier.Signature.toption)|`Alias(i,_)->Path.Resolved.parent_module_identifieri|`Module(m,n)->(matchsgidentifiermwith|None->None|Somep->Some(Identifier.Mk.module_(p,n)))|`OpaqueModulem->sgidentifier(m:>t)endmoduleModule=structtypet=Paths_types.Resolved_fragment.module_endmoduleModuleType=structtypet=Paths_types.Resolved_fragment.module_typeendmoduleType=structtypet=Paths_types.Resolved_fragment.type_endtypeleaf=Paths_types.Resolved_fragment.leafletrecidentifier:t->Identifier.toption=function|`Root(`ModuleType_r)->assertfalse|`Root(`Module_r)->assertfalse|`Subst(s,_)->(Path.Resolved.ModuleType.identifiers:>Identifier.toption)|`Alias(p,_)->(Path.Resolved.parent_module_identifierp:>Identifier.toption)|`Module(m,n)->(matchSignature.sgidentifiermwith|None->None|Somep->Some(Identifier.Mk.module_(p,n)))|`Module_type(m,n)->(matchSignature.sgidentifiermwith|None->None|Somep->Some(Identifier.Mk.module_type(p,n)))|`Type(m,n)->(matchSignature.sgidentifiermwith|None->None|Somep->Some(Identifier.Mk.type_(p,n)))|`Class(m,n)->(matchSignature.sgidentifiermwith|None->None|Somep->Some(Identifier.Mk.class_(p,n)))|`ClassType(m,n)->(matchSignature.sgidentifiermwith|None->None|Somep->Some(Identifier.Mk.class_type(p,n)))|`OpaqueModulem->identifier(m:>t)letrecis_hidden:t->bool=function|`Root(`ModuleTyper)->Path.Resolved.(is_hidden(r:>t))|`Root(`Moduler)->Path.Resolved.(is_hidden(r:>t))|`Subst(s,_)->Path.Resolved.(is_hidden(s:>t))|`Alias(s,_)->Path.Resolved.(is_hidden(s:>t))|`Module(m,_)|`Module_type(m,_)|`Type(m,_)|`Class(m,_)|`ClassType(m,_)->is_hidden(m:>t)|`OpaqueModulem->is_hidden(m:>t)endtypet=Paths_types.Fragment.anymoduleSignature=structtypet=Paths_types.Fragment.signatureendmoduleModule=structtypet=Paths_types.Fragment.module_endmoduleModuleType=structtypet=Paths_types.Fragment.module_typeendmoduleType=structtypet=Paths_types.Fragment.type_endtypeleaf=Paths_types.Fragment.leafendmoduleReference=structmoduleResolved=structopenPaths_types.Resolved_referencetypet=Paths_types.Resolved_reference.anyletrecparent_signature_identifier:signature->Identifier.Signature.toption=function|`Identifierid->Someid|`Hidden_s->None|`Alias(sub,orig)->ifPath.Resolved.(is_hidden(sub:>t))thenparent_signature_identifier(orig:>signature)else(Path.Resolved.parent_module_identifiersub:>Identifier.Signature.toption)|`AliasModuleType(sub,orig)->ifPath.Resolved.(is_hidden(sub:>t))thenparent_signature_identifier(orig:>signature)else(Path.Resolved.parent_module_type_identifiersub:>Identifier.Signature.toption)|`Module(m,n)->(matchparent_signature_identifiermwith|None->None|Somep->Some(Identifier.Mk.module_(p,n)))|`ModuleType(m,n)->(matchparent_signature_identifiermwith|None->None|Somep->Some(Identifier.Mk.module_type(p,n)))andparent_type_identifier:datatype->Identifier.DataType.toption=function|`Identifierid->Someid|`Type(sg,s)->(matchparent_signature_identifiersgwith|None->None|Somep->Some(Identifier.Mk.type_(p,s)))andparent_class_signature_identifier:class_signature->Identifier.ClassSignature.toption=function|`Identifierid->Someid|`Class(sg,s)->(matchparent_signature_identifiersgwith|None->None|Somep->Some(Identifier.Mk.class_(p,s)))|`ClassType(sg,s)->(matchparent_signature_identifiersgwith|None->None|Somep->Some(Identifier.Mk.class_type(p,s)))andfield_parent_identifier:field_parent->Identifier.FieldParent.toption=function|`Identifierid->Someid|(`Hidden_|`Alias_|`AliasModuleType_|`Module_|`ModuleType_)assg->(parent_signature_identifiersg:>Identifier.FieldParent.toption)|`Type_ast->(parent_type_identifiert:>Identifier.FieldParent.toption)andunboxed_field_parent_identifier:unboxed_field_parent->Identifier.UnboxedFieldParent.toption=function|`Identifierid->Someid|`Type_ast->(parent_type_identifiert:>Identifier.UnboxedFieldParent.toption)andlabel_parent_identifier:label_parent->Identifier.LabelParent.toption=function|`Identifierid->Someid|(`Class_|`ClassType_)asc->(parent_class_signature_identifierc:>Identifier.LabelParent.toption)|(`Hidden_|`Alias_|`AliasModuleType_|`Module_|`ModuleType_|`Type_)asr->(field_parent_identifierr:>Identifier.LabelParent.toption)andidentifier:t->Identifier.toption=function|`Identifierid->Someid|`UnboxedField(p,n)->(matchunboxed_field_parent_identifierpwith|None->None|Somep->Some(Identifier.Mk.unboxed_field(p,n)))|(`Alias_|`AliasModuleType_|`Module_|`Hidden_|`Type_|`Class_|`ClassType_|`ModuleType_)asr->(label_parent_identifierr:>Identifier.toption)|`Field(p,n)->(matchfield_parent_identifierpwith|None->None|Somep->Some(Identifier.Mk.field(p,n)))|`PolyConstructor(s,n)->((* Uses an identifier for constructor even though it is not
one. Document must make the links correspond. *)matchparent_type_identifierswith|None->None|Somep->Some(Identifier.Mk.constructor(p,n)))|`Constructor(s,n)->(matchparent_type_identifierswith|None->None|Somep->Some(Identifier.Mk.constructor(p,n)))|`Extension(p,q)->(matchparent_signature_identifierpwith|None->None|Somep->Some(Identifier.Mk.extension(p,q)))|`ExtensionDecl(p,q,r)->(matchparent_signature_identifierpwith|None->None|Somep->Some(Identifier.Mk.extension_decl(p,(q,r))))|`Exception(p,q)->(matchparent_signature_identifierpwith|None->None|Somep->Some(Identifier.Mk.exception_(p,q)))|`Value(p,q)->(matchparent_signature_identifierpwith|None->None|Somep->Some(Identifier.Mk.value(p,q)))|`Method(p,q)->(matchparent_class_signature_identifierpwith|None->None|Somep->Some(Identifier.Mk.method_(p,q)))|`InstanceVariable(p,q)->(matchparent_class_signature_identifierpwith|None->None|Somep->Some(Identifier.Mk.instance_variable(p,q)))|`Label(p,q)->(matchlabel_parent_identifierpwith|None->None|Somep->Some(Identifier.Mk.label(p,q)))moduleSignature=structtypet=Paths_types.Resolved_reference.signatureendmoduleClassSignature=structtypet=Paths_types.Resolved_reference.class_signatureendmoduleDataType=structtypet=Paths_types.Resolved_reference.datatypeendmoduleFieldParent=structtypet=Paths_types.Resolved_reference.field_parentendmoduleUnboxedFieldParent=structtypet=Paths_types.Resolved_reference.unboxed_field_parentendmoduleLabelParent=structtypet=Paths_types.Resolved_reference.label_parentendmoduleModule=structtypet=Paths_types.Resolved_reference.module_endmoduleModuleType=structtypet=Paths_types.Resolved_reference.module_typeendmoduleType=structtypet=Paths_types.Resolved_reference.type_endmoduleConstructor=structtypet=Paths_types.Resolved_reference.constructorendmoduleField=structtypet=Paths_types.Resolved_reference.fieldendmoduleUnboxedField=structtypet=Paths_types.Resolved_reference.unboxed_fieldendmoduleExtension=structtypet=Paths_types.Resolved_reference.extensionendmoduleExtensionDecl=structtypet=Paths_types.Resolved_reference.extension_declendmoduleException=structtypet=Paths_types.Resolved_reference.exception_endmoduleValue=structtypet=Paths_types.Resolved_reference.valueendmoduleClass=structtypet=Paths_types.Resolved_reference.class_endmoduleClassType=structtypet=Paths_types.Resolved_reference.class_typeendmoduleMethod=structtypet=Paths_types.Resolved_reference.method_endmoduleInstanceVariable=structtypet=Paths_types.Resolved_reference.instance_variableendmoduleLabel=structtypet=Paths_types.Resolved_reference.labelendmodulePage=structtypet=Paths_types.Resolved_reference.pageendmoduleAsset=structletidentifier=function`Identifierid->idtypet=Paths_types.Resolved_reference.assetendendtypet=Paths_types.Reference.anytypetag_any=Paths_types.Reference.tag_anytypetag_hierarchy=Paths_types.Reference.tag_hierarchymoduleSignature=structtypet=Paths_types.Reference.signatureendmoduleClassSignature=structtypet=Paths_types.Reference.class_signatureendmoduleDataType=structtypet=Paths_types.Reference.datatypeendmoduleFragmentTypeParent=structtypet=Paths_types.Reference.fragment_type_parentendmoduleLabelParent=structtypet=Paths_types.Reference.label_parentendmoduleModule=structtypet=Paths_types.Reference.module_endmoduleModuleType=structtypet=Paths_types.Reference.module_typeendmoduleType=structtypet=Paths_types.Reference.type_endmoduleConstructor=structtypet=Paths_types.Reference.constructorendmoduleField=structtypet=Paths_types.Reference.fieldendmoduleUnboxedField=structtypet=Paths_types.Reference.unboxed_fieldendmoduleExtension=structtypet=Paths_types.Reference.extensionendmoduleExtensionDecl=structtypet=Paths_types.Reference.extension_declendmoduleException=structtypet=Paths_types.Reference.exception_endmoduleValue=structtypet=Paths_types.Reference.valueendmoduleClass=structtypet=Paths_types.Reference.class_endmoduleClassType=structtypet=Paths_types.Reference.class_typeendmoduleMethod=structtypet=Paths_types.Reference.method_endmoduleInstanceVariable=structtypet=Paths_types.Reference.instance_variableendmoduleLabel=structtypet=Paths_types.Reference.labelendmodulePage=structtypet=Paths_types.Reference.pageendmoduleAsset=structtypet=Paths_types.Reference.assetendmoduleHierarchy=structtypet=Paths_types.Reference.hierarchyendend