Abstract
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.
Supplemental Material
- Acosta-Gómez, Alfonso. 2007. Hardware synthesis in ForSyDe. Master's thesis, Dept. of Microelectronics and Information Technology, Royal Institute of Technology, Stockholm, Sweden.Google Scholar
- Albert, Elvira, Michael Hanus, Frank Huch, Javier Oliver, and German Vidal. 2005. Operational semantics for declarative multi-paradigm languages. Journal of Symbolic Computation 40(1):795--829. Google Scholar
Digital Library
- Antoy, Sergio, and Michael Hanus. 2002. Functional logic design patterns. In FLOPS, 67--87. Google Scholar
Digital Library
- Antoy, Sergio, and Michael Hanus. 2006. Overlapping rules and logic variables in functional logic programs. In ICLP, 87--101. Google Scholar
Digital Library
- Ariola, Zena M., and Matthias Felleisen. 1997. The call-by-need lambda calculus. JFP 7(3):265--301. Google Scholar
Digital Library
- Ariola, Zena M., Matthias Felleisen, John Maraist, Martin Odersky, and Philip Wadler. 1995. The call-by-need lambda calculus. In POPL, 233--246. Google Scholar
Digital Library
- Bird, Richard, Geraint Jones, and Oege de Moor. 1997. More haste, less speed: Lazy versus eager evaluation. JFP 7(5):541--547. Google Scholar
Digital Library
- Bjesse, Per, Koen Claessen, Mary Sheeran, and Satnam Singh. 1998. Lava: Hardware design in Haskell. In ICFP, 174--184. Google Scholar
Digital Library
- Braßel, Bernd, and Frank Huch. 2009. The Kiel Curry System KiCS. In WLP 2007, 195--205.Google Scholar
- Christiansen, Jan, and Sebastian Fischer. 2008. EasyCheck - test data for free. In FLOPS, 322--336. Google Scholar
Digital Library
- Claessen, Koen, and John Hughes. 2000. QuickCheck: A lightweight tool for random testing of Haskell programs. In ICFP, 268--279. Google Scholar
Digital Library
- Escardó, Mart´1n H. 2007. Infinite sets that admit fast exhaustive search. In LICS, 443--452. Google Scholar
Digital Library
- Felleisen, Matthias. 1985. Transliterating Prolog into Scheme. Tech. Rep. 182, Computer Science Dept., Indiana University.Google Scholar
- Filinski, Andrzej. 1999. Representing layered monads. In POPL, 175--188. Google Scholar
Digital Library
- Fischer, Sebastian, and Herbert Kuchen. 2007. Systematic generation of glass-box test cases for functional logic programs. In PPDP, 63--74. Google Scholar
Digital Library
- Garcia, Ronald, Andrew Lumsdaine, and Amr Sabry. 2009. Lazy evaluation and delimited control. In POPL, 153--164. Google Scholar
Digital Library
- González-Moreno, Juan Carlos, Maria Teresa Hortalá-González, Francisco Javier López-Fraguas, and Mario Rodr´1guez-Artalejo. 1999. An approach to declarative programming based on a rewriting logic. Journal of Logic Programming 40(1):47--87.Google Scholar
Cross Ref
- Goodman, Noah, Vikash K. Mansinghka, Daniel Roy, Keith Bonawitz, and Joshua B. Tenenbaum. 2008. Church: A language for generative models. In UAI, 220--229.Google Scholar
- Haynes, Christopher T. 1987. Logic continuations. Journal of Logic Programming 4(2):157--176. Google Scholar
Digital Library
- Hinze, Ralf. 2000. Deriving backtracking monad transformers (functional pearl). In ICFP, 186--197. Google Scholar
Digital Library
- Hudak, Paul. 1996. Building domain-specific embedded languages. ACM Computing Surveys 28(4es):196. Google Scholar
Digital Library
- Hughes, John. 1989. Why functional programming matters. The Computer Journal 32(2):98--107. Google Scholar
Digital Library
- Kiselyov, Oleg, and Chung-chieh Shan. 2009. Embedded probabilistic programming. In Working conf. on domain specific lang. Google Scholar
Digital Library
- Kiselyov, Oleg, Chung-chieh Shan, Daniel P. Friedman, and Amr Sabry. 2005. Backtracking, interleaving, and terminating monad transformers (functional pearl). In ICFP, 192--203. Google Scholar
Digital Library
- Koller, Daphne, David McAllester, and Avi Pfeffer. 1997. Effective Bayesian inference for stochastic programs. In AAAI, 740--747. Google Scholar
Digital Library
- Lämmel, Ralf, and Simon L. Peyton Jones. 2003. Scrap your boilerplate: A practical design pattern for generic programming. In TLDI, 26--37.Google Scholar
- Launchbury, John. 1993. A natural semantics for lazy evaluation. In POPL, 144--154. Google Scholar
Digital Library
- Lin, Chuan-kai. 2006. Programming monads operationally with Unimo. In ICFP, 274--285. Google Scholar
Digital Library
- López-Fraguas, Francisco Javier, Juan Rodríguez-Hortalá, and Jaime Sánchez-Hernández. 2007. A simple rewrite notion for call-time choice semantics. In PPDP, 197--208. Google Scholar
Digital Library
- López-Fraguas, Francisco Javier, Juan Rodríguez-Hortalá, and Jaime Sánchez-Hernández. 2008. Rewriting and call-time choice: The HO case. In FLOPS, 147--162. Google Scholar
Digital Library
- Maraist, John, Martin Odersky, and Philip Wadler. 1998. The call-by-need lambda calculus. JFP 8(3):275--317. Google Scholar
Digital Library
- McCarthy, John. 1963. A basis for a mathematical theory of computation. In Computer programming and formal systems, 33--70. North-Holland.Google Scholar
- Michie, Donald. 1968. "Memo" functions and machine learning. Nature 218:19--22.Google Scholar
Cross Ref
- MonadPlus. 2008. MonadPlus. http://www.haskell.org/haskellwiki/MonadPlus.Google Scholar
- Morrisett, J. Gregory. 1993. Refining first-class stores. In Proceedings of the workshop on state in programming languages.Google Scholar
- Naylor, Matthew, Emil Axelsson, and Colin Runciman. 2007. A functional-logic library for Wired. In Haskell workshop, 37--48. Google Scholar
Digital Library
- Nicollet, Victor, et al. 2009. Lazy and threads. http://caml.inria.fr/pub/ml-archives/caml-list/2009/02/9fc4e4a897ce7a356674660c8cfa5ac0.fr.html.Google Scholar
- Nordin, Thomas, and Andrew Tolmach. 2001. Modular lazy search for constraint satisfaction problems. JFP 11(5):557--587. Google Scholar
Digital Library
- Rabin, Michael O., and Dana Scott. 1959. Finite automata and their decision problems. IBM Journal of Research and Development 3:114--125.Google Scholar
Digital Library
- Runciman, Colin, Matthew Naylor, and Fredrik Lindblad. 2008.Google Scholar
- SmallCheck and Lazy SmallCheck: Automatic exhaustive testing for small values. In Haskell symposium, 37--48. Google Scholar
Digital Library
- Seaman, Jill M. 1993. An operational semantics of lazy evaluation for analysis. Ph.D. thesis, Pennsylvania State University. Google Scholar
Digital Library
- Spivey, J. Michael. 2000. Combinators for breadth-first search. JFP 10(4):397--408. Google Scholar
Digital Library
- Tolmach, Andrew, and Sergio Antoy. 2003. A monadic semantics for core Curry. In WFLP, 33--46. Valencia, Spain.Google Scholar
- Tolmach, Andrew, Sergio Antoy, and Marius Nita. 2004. Implementing functional logic languages using multiple threads and stores. In ICFP, 90--102. Google Scholar
Digital Library
- de Vries, Edsko. 2009. Just how unsafe is unsafe. http://www.haskell.org/pipermail/haskell-cafe/2009-February/055201.html.Google Scholar
- Wadler, Philip L. 1985. How to replace failure by a list of successes: A method for exception handling, backtracking, and pattern matching in lazy functional languages. In FPCA, 113--128. Google Scholar
Digital Library
Index Terms
Purely functional lazy non-deterministic programming
Recommendations
Purely functional lazy non-deterministic programming
ICFP '09: Proceedings of the 14th ACM SIGPLAN international conference on Functional programmingFunctional 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 ...
Purely functional lazy nondeterministic programming
Dedicated to ICFP 2009Functional logic programming and probabilistic programming have demonstrated the broad benefits of combining laziness (nonstrict evaluation with sharing of the results) with nondeterminism. Yet these benefits are seldom enjoyed in functional programming ...
When is a functional program not a functional program?
ICFP '99: Proceedings of the fourth ACM SIGPLAN international conference on Functional programmingIn an impure functional language, there are programs whose behaviour is completely functional (in that they behave extensionally on inputs), but the functions they compute cannot be written in the purely functional fragment of the language. That is, the ...







Comments