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

@article{Pirg2017BacktrackingWC, title={Backtracking with cut via a distributive law and left-zero monoids*}, author={Maciej Pir{\'o}g and Sam Staton}, journal={Journal of Functional Programming}, year={2017}, volume={27} }

Abstract 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.

## 6 Citations

### No-Go Theorems for Distributive Laws

- Mathematics2019 34th Annual ACM/IEEE Symposium on Logic in Computer Science (LICS)
- 2019

Two families of theorems for showing when there can be no distributive law for two monads are presented, widely generalizing a counterexample attributed to Plotkin and encompassing various new practical situations.

### Equational Theories and Monads from Polynomial Cayley Representations

- MathematicsFoSSaCS
- 2019

CayMon, a tool that takes a polynomial as an input and generates the corresponding equational theory together with the two implementations of the induced monad in Haskell is introduced.

### Preservation of Equations by Monoidal Monads

- MathematicsMFCS
- 2020

This paper shows a converse: if the monad at hand preserves a drop equation, then it must be affine, and shows that the problem whether a given (drop) equation is preserved is undecidable.

### 123 Flexible Presentations of Graded Monads

- Mathematics
- 2022

A large class of monads used to model computational effects have natural presentations by operations and equations, for example, the list monad can be presented by a constant and a binary operation…

### Don't Try This at Home: No-Go Theorems for Distributive Laws

- MathematicsArXiv
- 2018

This work develops general-purpose techniques for showing when there can be no distributive law between two monads, and adopts an algebraic perspective throughout, exploiting a syntactic characterization of distributive laws.

### Flexible presentations of graded monads

- MathematicsProceedings of the ACM on Programming Languages
- 2022

A large class of monads used to model computational effects have natural presentations by operations and equations, for example, the list monad can be presented by a constant and a binary operation…

## References

SHOWING 1-10 OF 15 REFERENCES

### Eilenberg-Moore Monoids and Backtracking Monad Transformers

- MathematicsMSFP
- 2016

An algebraic underpinning of backtracking monad transformers in the general setting of monoidal categories is developed and an Eilenberg–Moore monoid of endomorphisms is constructed, which, via the codensity monad construction, yields a continuation-based implementation a la Hinze.

### Deriving backtracking monad transformers

- Computer ScienceICFP '00
- 2000

This work applies two fundamental techniques for deriving programs from their specification to derive a backtracking monad transformer that adds backtracking to an arbitrary monad.

### Computational Effects and Operations: An Overview

- Computer ScienceElectron. Notes Theor. Comput. Sci.
- 2004

### Simple Operational and Denotational Semantics for Prolog with Cut

- Computer ScienceTheor. Comput. Sci.
- 1990

### Kan Extensions for Program Optimisation Or: Art and Dan Explain an Old Trick

- BusinessMPC
- 2012

The theoretical underpinnings of so-called absolute Kan Extensions underlie this program optimisation, and a two-dimensional notation based on string diagrams is proposed that aims to support effective reasoning with Kan extensions.

### Term rewriting and all that

- EducationSOEN
- 2000

Term Rewriting and All That is a self-contained introduction to the field of term rewriting and covers all the basic material including abstract reduction systems, termination, confluence, completion, and combination problems.

### Handling Algebraic Effects

- Computer ScienceLog. Methods Comput. Sci.
- 2013

This work generalises exception handlers to arbitrary algebraic effects, and includes many previously unrelated examples from both theory and practice, including relabelling and restriction in Milner's CCS, timeout, rollback, and stream redirection.