Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file path.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190openCoreopenCore_profilertype'apoint=|Direct_pointof'a|Pointof'a[@@derivingsexp,compare]type'idt={first:'idpoint(* i.e., penultimate point first *);rest_rev:'idpointlist;last:'id}[@@derivingsexp,compare]letfirstt=matcht.firstwith|Direct_pointi->i|Pointi->iletlastt=t.lastletdirect_sep=","letindirect_sep=".."letnextstrpos=letnext_pospattern=String.substr_indexstr~pos~patterninletsubpos2=String.substr~pos:pos~len:(pos2-pos)inmatch(next_posindirect_sep,next_posdirect_sep)with|(Somea,None)->Some(Point(suba),a+String.lengthindirect_sep)|(None,Someb)->Some(Direct_point(subb),b+String.lengthdirect_sep)|(Somea,Someb)->ifa<bthenSome(Point(suba),a+String.lengthindirect_sep)elseSome(Direct_point(subb),b+String.lengthdirect_sep)|(None,None)->Noneletstring_t_of_stringstr=let(>>|)=Option.(>>|)innextstr0>>|fun(first,first_pos)->letrecloopposrest_rev=matchnextstrposwith|Some(pt,new_pos)->loopnew_pos(pt::rest_rev)|None->letlast=String.substr~pos~len:(String.lengthstr-pos)in{last;rest_rev;first}inloopfirst_pos[]letstring_t_to_string{first;rest_rev;last}=letpoint_to_string=function|Direct_pointname->[name;direct_sep]|Pointname->[name;indirect_sep]in(point_to_stringfirst::List.rev_maprest_rev~f:point_to_string@[[last]])|>List.concat|>String.concatlet%test_module_=(modulestructletchecksp=[%test_eq:stringtoption](string_t_of_strings)(Somep);[%test_eq:string](string_t_to_stringp)slet%test_unit"aaa..bbb"=check"aaa..bbb"{last="bbb";rest_rev=[];first=Point"aaa"}let%test_unit"aaa..b..cc..ddd"=check"aaa..b..cc..ddd"{first=Point"aaa";rest_rev=[Point"cc";Point"b"];last="ddd"}let%test_unit"aaa,bbb"=check"aaa,bbb"{first=Direct_point"aaa";rest_rev=[];last="bbb"}let%test_unit"a..b,c..d,e"=check"a..b,c..d,e"{first=Point"a";rest_rev=[Direct_point"d";Point"c";Direct_point"b"];last="e"}end)letexamples=[{first=Point"a";last="b";rest_rev=[]};{first=Direct_point"b";rest_rev=[Direct_point"d";Point"c"];last="e"}]letreadme=lazy(letexamples=examples|>List.map~f:(funp->" "^string_t_to_stringp)|>String.concatin"To describe a path, specify a sequence of points. The separator determines whether \
whether you would like to consider paths that went from a to b directly (\"a.b\"), \
or paths that went from a to b, possibly (but not necessarily) via some other \
points (\"a..b\"). \
A point may not appear twice, except for when its second appearance is as the last \
point in the path.\n\n\
Some examples:"^examples)letlookup_idspath{Util.Name_map.children=name_map;_}=letlookup_point=function|Pointp->Point(Map.find_exnname_mapp)|Direct_pointp->Direct_point(Map.find_exnname_mapp)in{first=lookup_pointpath.first;rest_rev=List.map~f:lookup_pointpath.rest_rev;last=Map.find_exnname_mappath.last}letlookup_namespathid_map=letget_name=Fn.composeReader.Header.Item.name(Reader.Header.find_exnid_map)inletlookup_point=function|Pointp->Point(get_namep)|Direct_pointp->Direct_point(get_namep)in{first=lookup_pointpath.first;rest_rev=List.map~f:lookup_pointpath.rest_rev;last=get_namepath.last}letid_t_to_stringpath?with_groupid_map=beginmatchwith_groupwith|Somesep->letgroup_name=Reader.Header.((get_parent_exnid_mappath.last).Item.name)ingroup_name^sep|None->""end^string_t_to_string(lookup_namespathid_map)moduleI=structtypeid_path=Probe_id.tt[@@derivingsexp,compare]moduleT=structtypet=id_path[@@derivingsexp,compare]lethash_point=function|Direct_pointid->Probe_id.to_int_exnid|Pointid->Probe_id.to_int_exnid+(1lsl17-1)lethash{last;rest_rev;first}=letproduct=List.foldrest_rev~init:1~f:(funaccumpt->(accum*hash_pointpt)mod(1lsl31-1))*hash_pointfirst*Probe_id.to_int_exnlastinInt.hashproductendincludeTincludeComparable.Make(T)includeHashable.Make_and_derive_hash_fold_t(T)end