Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file how_to_diff.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215open!BaseopenPpxlibmoduleAtomic=structtypet={using_compare:bool}[@@derivingenumerate,equal,compare]letto_string{using_compare}="atomic"^ifusing_comparethen"_using_compare"else"";;endmoduleLabel=structlethow="how"letkey="key"letelt="elt"endmoduleType_=structtypet=core_typeletpattern=letopenAst_patterninletident=map'(pexp_ident__)~f:(funloc_lid->Some(Ast_builder.Default.ptyp_constr~loc(Ast_builder.Default.Located.mk~loclid)[]))inlettype_=pexp_extension(extension(string"diff.type")(ptyp__))inaltidenttype_;;letoptional_pattern~label=letopenAst_patterninletpattern=Ast_pattern.(single_expr_payload(pexp_constraint(pexp_ident(lident(stringlabel)))__))inalt_optionpattern(pstrnil);;endmoduleCustom=structmoduleFlat=structtypet=|AtomicofAtomic.t|As_set|As_map[@@derivingenumerate,compare]letto_string=function|Atomicatomic->Atomic.to_stringatomic|As_set->"set"|As_map->"map";;letattribute_txtt=letname=Shared.name_of_ppxin"ppx_"^name^"."^name^"."^to_stringt;;letto_attribute_stringt="[@"^String.filter(attribute_txtt)~f:(Char.(<>)'@')^"]";;endtypet=|AtomicofAtomic.t|As_setof{elt:core_typeoption}|As_mapof{key:core_typeoption}letattribute(flat:Flat.t)context_kind:(_,t)Attribute.t=letattribute_txt=Flat.attribute_txtflatinletdeclarepatternreturn=Attribute.declareattribute_txtcontext_kindpatternreturninmatchflatwith|Atomicatomic->declareAst_pattern.(pstrnil)(Atomicatomic)|As_set->declare(Type_.optional_pattern~label:Label.elt)(funelt->As_set{elt})|As_map->declare(Type_.optional_pattern~label:Label.key)(funkey->As_map{key});;letof_attributescontext_kind=letattributeflat=attributeflatcontext_kindinletattrs=List.mapFlat.all~f:attributeinStaged.stage(funvalue~builder->matchList.filter_mapattrs~f:(funattr->Attribute.getattrvalue)with|[]->None|[t]->Somet|_::_->letopen(valbuilder:Builder.S)inraise_error(Printf.sprintf"at most one of %s can be specified"(List.mapFlat.all~f:Flat.to_attribute_string|>List.sort~compare:String.compare|>String.concat~sep:", ")));;letto_flat=function|Atomicatomic->Flat.Atomicatomic|As_set_->As_set|As_map_->As_map;;letto_stringt=Flat.to_string(to_flatt)letto_attribute_stringt=Flat.to_attribute_string(to_flatt)letof_core_type=of_attributesCore_type|>Staged.unstageletof_label_declaration=of_attributesLabel_declaration|>Staged.unstageletof_constructor_declaration=of_attributesConstructor_declaration|>Staged.unstageletof_rtag=of_attributesRtag|>Staged.unstagemoduleOr_abstract=structmoduleFlat=structtypet=|CustomofFlat.t|Abstract[@@derivingenumerate,compare]letto_string=function|Customcustom->Flat.to_stringcustom|Abstract->"abstract";;letof_string=letall=List.mapall~f:(funt->to_stringt,t)|>Map.of_alist_exn(moduleString)infuns~builder->letopen(valbuilder:Builder.S)inmatchMap.findallswith|None->raise_error(Printf.sprintf"Unknown how to diff: %s. Known values are: %s"s(Map.keysall|>String.concat~sep:", "))|Somet->t;;endtypenonrect=|Customoft|Abstractletto_flatt:Flat.t=matchtwith|Customcustom->Custom(to_flatcustom)|Abstract->Abstract;;letto_stringt=Flat.to_string(to_flatt)endendmoduleMaybe_abstract=structtypet=Custom.Or_abstract.toptionletcreate~how~key~elt~builder=letopenCustom.Or_abstractinletopen(valbuilder:Builder.S)inlethow=Option.maphow~f:(Flat.of_string~builder)inleterror~not_supported=letlabel=function|`key->Label.key|`elt->Label.eltinletsupported_for=function|`key->Flat.CustomAs_map|`elt->Flat.CustomAs_setinletdid_you_mean=matchnot_supportedwith|`key->`elt|`elt->`keyinletmaybe_hint=matchhowwith|None->""|Somehow->ifFlat.compare(supported_fordid_you_mean)how<>0then""elsePrintf.sprintf" Since you are using %s=\"%s\", did you mean to use \"%s\" instead of \
\"%s\"?"Label.how(Flat.to_stringhow)(labeldid_you_mean)(labelnot_supported)inraise_error(Printf.sprintf"\"%s\" can only be specified when %s=\"%s\".%s"(labelnot_supported)Label.how(Flat.to_string(supported_fornot_supported))maybe_hint)inmatchhow,key,eltwith|None,None,None->None|SomeAbstract,None,None->SomeAbstract|Some(Custom(Atomicatomic)),None,None->Some(Custom(Atomicatomic))|Some(CustomAs_map),key,None->Some(Custom(As_map{key}))|Some(CustomAs_set),None,elt->Some(Custom(As_set{elt}))|_,Some_,_->error~not_supported:`key|_,_,Some_->error~not_supported:`elt;;endtypet=Custom.toption