12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697open!Import(* In the definition of [t], we do not have [[@@deriving compare, sexp]] because
in general, syntax extensions tend to use the implementation when available rather than
using the alias. Here that would lead to use the record representation [ { mutable
contents : 'a } ] which would result in different (and unwanted) behavior. *)type'at='aref={mutablecontents:'a}include(structtype'at='aref[@@deriving_inlinecompare,equal,sexp,sexp_grammar]letcompare:'a.('a->'a->int)->'at->'at->int=compare_refletequal:'a.('a->'a->bool)->'at->'at->bool=equal_reflett_of_sexp:'a.(Ppx_sexp_conv_lib.Sexp.t->'a)->Ppx_sexp_conv_lib.Sexp.t->'at=ref_of_sexp;;letsexp_of_t:'a.('a->Ppx_sexp_conv_lib.Sexp.t)->'at->Ppx_sexp_conv_lib.Sexp.t=sexp_of_ref;;let(t_sexp_grammar:Ppx_sexp_conv_lib.Sexp.Private.Raw_grammar.t)=let(_the_generic_group:Ppx_sexp_conv_lib.Sexp.Private.Raw_grammar.generic_group)={implicit_vars=["ref"];ggid="j\132);\135qH\158\135\222H\001\007\004\158\218";types=["t",Explicit_bind(["a"],Apply(Implicit_var0,[Explicit_var0]))]}inlet(_the_group:Ppx_sexp_conv_lib.Sexp.Private.Raw_grammar.group)={gid=Ppx_sexp_conv_lib.Lazy_group_id.create();apply_implicit=[ref_sexp_grammar];generic_group=_the_generic_group;origin="ref.ml"}inlet(t_sexp_grammar:Ppx_sexp_conv_lib.Sexp.Private.Raw_grammar.t)=Ref("t",_the_group)int_sexp_grammar;;[@@@end]end:sigtype'at='aref[@@deriving_inlinecompare,equal,sexp,sexp_grammar]valcompare:('a->'a->int)->'at->'at->intvalequal:('a->'a->bool)->'at->'at->boolincludePpx_sexp_conv_lib.Sexpable.S1withtype'at:='atvalt_sexp_grammar:Ppx_sexp_conv_lib.Sexp.Private.Raw_grammar.t[@@@end]endwithtype'at:='at)externalcreate:'a->'at="%makemutable"external(!):'at->'a="%field0"external(:=):'at->'a->unit="%setfield0"letswapt1t2=lettmp=!t1int1:=!t2;t2:=tmp;;letreplacetf=t:=f!tletset_temporarilyta~f=letrestore_to=!tint:=a;Exn.protect~f~finally:(fun()->t:=restore_to);;moduleAnd_value=structtypet=T:'aref*'a->t[@@derivingsexp_of]letset(T(r,a))=r:=aletsetsts=List.iterts~f:setletsnapshot(T(r,_))=T(r,!r)letsnapshotsts=List.mapts~f:snapshotendletsets_temporarilyand_values~f=letrestore_to=And_value.snapshotsand_valuesinAnd_value.setsand_values;Exn.protect~f~finally:(fun()->And_value.setsrestore_to);;