12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758openPpxlibopenBaseletstr_gen~loc~path:_(_rec,t)=lett=List.hd_exntinlet(moduleAst)=Ast_builder.makelocinletfields=matcht.ptype_kindwith|Ptype_recordfields->Somefields|_->None(* Location.raise_errorf ~loc "Matcher only works on records" *)inmatchfieldswith|None->[]|Somefields->letlident_of_fieldfield=Ast_builder.Default.Located.lident~loc:field.pld_name.locfield.pld_name.txtinletpat=lettype_name=t.ptype_name.txtinAst.pvar(ifString.equaltype_name"t"then"have"elsetype_name^"_matcher")inletexpr=letbody=letinit=[%exprOk()]infields|>List.fold_right~init~f:(funfielditer->letlident_actual=Loc.make~loc(Longident.parse"actual")in[%expr[%eiter]|>Speed.Assertions.AssertionResult.bind~f:(fun_->match[%eAst.pexp_ident(lident_of_fieldfield)]with|None->Ok()|Somev->[%eAst.pexp_field(Ast.pexp_identlident_actual)(lident_of_fieldfield)]|>v|>Speed.Assertions.AssertionResult.mapignore)])inletinit=[%exprfunactual->[%ebody]]infields|>List.fold_right~init~f:(funnameinner->Ast.pexp_fun(Optionalname.pld_name.txt)None(Ast.ppat_varname.pld_name)inner)in[[%strilet[%ppat]=[%eexpr]]];;letstr_type_decl=Deriving.Generator.make_noargstr_genletmy_deriver=Deriving.add~str_type_decl"matcher"