Backtracking, interleaving, and terminating monad transformers (functional pearl)

Oleg Kiselyov, Chung Chieh Shan, Amr Sabry, Daniel P. Friedman

Research output: Contribution to journalArticlepeer-review

23 Citations (Scopus)


We design and implement a library for adding backtracking computations to any Haskell monad. Inspired by logic programming, our library provides, in addition to the operations required by the MonadPlus interface, constructs for fair disjunctions, fair conjunctions, conditionals, pruning, and an expressive top-level interface. Implementing these additional constructs is easy in models of backtracking based on streams, but not known to be possible in continuation-based models. We show that all these additional constructs can be genetically and monadically realized using a single primitive msplit. We present two implementations of the library: one using success and failure continuations; and the other using control operators for manipulating delimited continuations.

Original languageEnglish
Pages (from-to)192-203
Number of pages12
JournalACM SIGPLAN Notices
Issue number9
Publication statusPublished - 2005
Externally publishedYes


  • Continuations
  • Control delimiters
  • Haskell
  • Logic programming
  • Prolog
  • Streams

ASJC Scopus subject areas

  • Software
  • Computer Graphics and Computer-Aided Design


Dive into the research topics of 'Backtracking, interleaving, and terminating monad transformers (functional pearl)'. Together they form a unique fingerprint.

Cite this