Backtracking with cut via a distributive law and left-zero monoids

MACIEJ PIRÓG, SAM STATON
2017 Journal of functional programming  
We employ the framework of algebraic effects to augment the list monad with the pruning cut operator known from Prolog. We give two descriptions of the resulting monad: as the monad of free left-zero monoids, and as a composition via a distributive law of the list monad and the 'unary idempotent operation' monad. The scope delimiter of cut arises as a handler.
doi:10.1017/s0956796817000077 fatcat:ziro3piclvg6hgwrc5xvmxx6pq