1234567891011121314151617181920212223242526272829303132333435363738394041moduleMap=structincludeMap.Make(String)letfind_def0km=matchfind_optkmwithSomen->n|None->0end(* TODO: use ints or an ADT instead of strings for keys, though strings
give a convenient practicality. *)typet=intMap.tletempty=Map.emptytypefeat=stringletunionm1m2=Map.union(funkeyv1v2->matchkeywith|"depth"->Some(Int.maxv1v2)(* actually max_depth *)|_->Some(v1+v2))m1m2letincr_featkeym=Map.updatekey(functionNone->Some1|Somec->Some(c+1))mletget_featkeym=Map.find_def0keymletadd_timetimem=Map.add"time"timemletadd_depthdepthm=Map.add"depth"depthmletget_depthm=Map.find_def0"depth"mletadd_nb_queriesnb_exprs=Map.add"nb_queries"nb_exprsletadd_mean_depthmean_depth=Map.add"mean_depth"mean_depthletrename_depth_to_max_depthm=Map.add"max_depth"(matchMap.find_opt"depth"mwithNone->assertfalse|Somev->v)(Map.remove"depth"m)