The LP section contains a surprisingly concise solution for the n-queens problem and a lazy implementation of breadth-first search with a circular queue.

If you find time to read it, I’d be interested in whether you could follow easily or—if not—where you got stuck (especially if you are not very familiar with functional and/or logic programming).

]]>comments appreciated!

]]>The most important changes are:

- a simplified implementation of iterative deepening depth-first search and
- an additional section with experimental results.

There is also an extended one page abstract summarising the work.

Almost ten years ago, Ralf Hinze has written a functional pearl on how to derive backtracking functionality for the purely functional programming language Haskell. In these notes, we show how to arrive at the efficient, two-continuation based backtracking monad derived by Hinze starting from an intuitive inefficient implementation that we subsequently refine using well known program transformations.

It turns out that the technique can be used to build monads for non-determinism from modular, independent parts which gives rise to various new implementations. Specifically, we show how the presented approach can be applied to obtain new implementations of breadth-first search and iterative deepening depth-first search.

]]>

Functional logic programming and probabilistic programming have demonstrated the broad benefits of combining laziness (non-strict evaluation with sharing of the results) with non-determinism. Yet these benefits are seldom enjoyed in functional programming, because the existing features for non-strictness, sharing, and non-determinism in functional languages are tricky to combine.

We present a practical way to write purely functional lazy non-deterministic programs that are efficient and perspicuous. We achieve this goal by embedding the programs into existing languages (such as Haskell, SML, and OCaml) with high-quality implementations, by making choices lazily and representing data with non-deterministic components, by working with custom monadic data types and search strategies, and by providing equational laws for the programmer to reason about their code.

© ACM, 2009. This is the author’s version of the work. It is posted here by permission of ACM for your personal use. Not for redistribution. The definitive version will be published in Proceedings of the International Conference on Functional Programming (ICFP).

]]>I did it twice, first re-inventing the two-continuation model for depth-first search, then discovering an implementation of breadth-first search that I didn’t know before.

On the go, I used higher-rank infix record selectors for the first time.

In this program I talk about monads for non-determinism, functional lists, continuations, and what you get for free when you combine them.

]]>