1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950(* This file is free software, part of Zipperposition. See file "license" for more details. *)(** {1 Simplification Monad} *)type+'at='a*[`Same|`New]letreturn_samex=x,`Sameletreturn_newx=x,`Newletreturn=return_sameletget=fstletis_new(_,st)=matchstwith`New->true|`Same->falseletis_same(_,st)=matchstwith`New->false|`Same->trueletmapf(x,st)=fx,stletreturn_opt~old=function|None->return_sameold|Somex->return_newx(* chaining simplifications *)let(>>=)(c,state)f=letc',state2=fcinletstate_res=matchstate,state2with|`Same,`Same->`Same|`New,_|_,`New->`Newinc',state_resletrecapp_listlx=matchlwith|[]->return_samex|f::l'->fx>>=app_listl'letrecmap_lfl=matchlwith|[]->return_same[]|x::tail->fx>>=funx'->map_lftail>>=funtail'->return_same(x'::tail')letrecfold_lfaccl=matchlwith|[]->return_sameacc|x::tail->faccx>>=funacc->fold_lfacctailmoduleInfix=structlet(>>=)=(>>=)let(>|=)xf=mapfxend