12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455openCoreopen!Importtype'at=(* We specialize some cutoffs to avoid an indirect function call; in particular we
specialize the default (and hence overwhelmingly common) case of physical
equality. *)|Always|Never|Phys_equal|Compareof('a->'a->int)|Equalof('a->'a->bool)|Fof(old_value:'a->new_value:'a->bool)[@@derivingsexp_of]letinvariant_t=Invariant.invariant[%here]t[%sexp_of:_t](fun()->matchtwith|Always|Never|Phys_equal|Compare_|Equal_|F_->());;letcreatef=Ffletof_comparef=Comparefletof_equalf=Equalfletnever=Neverletalways=Alwaysletpoly_equal=EqualPoly.equalletshould_cutofft~old_value~new_value=matchtwith|Phys_equal->phys_equalold_valuenew_value|Never->false|Always->true|Comparef->fold_valuenew_value=0|Equalf->fold_valuenew_value|Ff->f~old_value~new_value;;letequalt1t2=matcht1,t2with|Always,Always->true|Always,_->false|Never,Never->true|Never,_->false|Phys_equal,Phys_equal->true|Phys_equal,_->false|Comparef1,Comparef2->phys_equalf1f2|Compare_,_->false|Equalf1,Equalf2->phys_equalf1f2|Equal_,_->false|Ff1,Ff2->phys_equalf1f2|F_,_->false;;letphys_equal=Phys_equal