From Non-determinism to Goroutines: A Fair Implementation of Curry in Go

by Jonas Böhm, Michael Hanus, Finn Teegen

Proc. of the 23rd International Symposium on Principles and Practice of Declarative Programming (PPDP 2021), ACM Press, pp. 16:1-16:16, 2021
© ACM Press

The declarative programming language Curry amalgamates demand-driven evaluation from functional programming with non-determinism from logic programming. In contrast to Prolog, the search strategy for non-deterministic computations is not fixed so that complete or parallel strategies are reasonable for Curry. In particular, a desirable option is a fair strategy which frees the programmer from considering the influence of the search strategy to the success of a computation. In this paper we describe an implementation with this property. Based on recent developments on operational models for functional logic programming, we present a new implementation which transforms Curry programs in several transformation steps into Go programs. By exploiting lightweight threads in the form of goroutines, we obtain a complete and fair implementation which automatically uses multi-processing to speed up non-deterministic computations. This has the effect that, in some cases, non-deterministic algorithms are more efficiently evaluated than deterministic ones.

Preprint (PDF) BibTeX-Entry Online