skip to main content
research-article

Purely functional lazy non-deterministic programming

Published:31 August 2009Publication History
Skip Abstract Section

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.

Skip Supplemental Material Section

Supplemental Material

purelyfunctionallazynon-deterministicprogrammingonvimeo.mp4

References

  1. 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 ScholarGoogle Scholar
  2. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  3. Antoy, Sergio, and Michael Hanus. 2002. Functional logic design patterns. In FLOPS, 67--87. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Antoy, Sergio, and Michael Hanus. 2006. Overlapping rules and logic variables in functional logic programs. In ICLP, 87--101. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Ariola, Zena M., and Matthias Felleisen. 1997. The call-by-need lambda calculus. JFP 7(3):265--301. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Ariola, Zena M., Matthias Felleisen, John Maraist, Martin Odersky, and Philip Wadler. 1995. The call-by-need lambda calculus. In POPL, 233--246. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Bird, Richard, Geraint Jones, and Oege de Moor. 1997. More haste, less speed: Lazy versus eager evaluation. JFP 7(5):541--547. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Bjesse, Per, Koen Claessen, Mary Sheeran, and Satnam Singh. 1998. Lava: Hardware design in Haskell. In ICFP, 174--184. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Braßel, Bernd, and Frank Huch. 2009. The Kiel Curry System KiCS. In WLP 2007, 195--205.Google ScholarGoogle Scholar
  10. Christiansen, Jan, and Sebastian Fischer. 2008. EasyCheck - test data for free. In FLOPS, 322--336. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Claessen, Koen, and John Hughes. 2000. QuickCheck: A lightweight tool for random testing of Haskell programs. In ICFP, 268--279. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Escardó, Mart´1n H. 2007. Infinite sets that admit fast exhaustive search. In LICS, 443--452. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Felleisen, Matthias. 1985. Transliterating Prolog into Scheme. Tech. Rep. 182, Computer Science Dept., Indiana University.Google ScholarGoogle Scholar
  14. Filinski, Andrzej. 1999. Representing layered monads. In POPL, 175--188. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Fischer, Sebastian, and Herbert Kuchen. 2007. Systematic generation of glass-box test cases for functional logic programs. In PPDP, 63--74. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Garcia, Ronald, Andrew Lumsdaine, and Amr Sabry. 2009. Lazy evaluation and delimited control. In POPL, 153--164. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. 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 ScholarGoogle ScholarCross RefCross Ref
  18. 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 ScholarGoogle Scholar
  19. Haynes, Christopher T. 1987. Logic continuations. Journal of Logic Programming 4(2):157--176. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Hinze, Ralf. 2000. Deriving backtracking monad transformers (functional pearl). In ICFP, 186--197. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Hudak, Paul. 1996. Building domain-specific embedded languages. ACM Computing Surveys 28(4es):196. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Hughes, John. 1989. Why functional programming matters. The Computer Journal 32(2):98--107. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Kiselyov, Oleg, and Chung-chieh Shan. 2009. Embedded probabilistic programming. In Working conf. on domain specific lang. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  25. Koller, Daphne, David McAllester, and Avi Pfeffer. 1997. Effective Bayesian inference for stochastic programs. In AAAI, 740--747. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Lämmel, Ralf, and Simon L. Peyton Jones. 2003. Scrap your boilerplate: A practical design pattern for generic programming. In TLDI, 26--37.Google ScholarGoogle Scholar
  27. Launchbury, John. 1993. A natural semantics for lazy evaluation. In POPL, 144--154. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Lin, Chuan-kai. 2006. Programming monads operationally with Unimo. In ICFP, 274--285. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  30. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  31. Maraist, John, Martin Odersky, and Philip Wadler. 1998. The call-by-need lambda calculus. JFP 8(3):275--317. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. McCarthy, John. 1963. A basis for a mathematical theory of computation. In Computer programming and formal systems, 33--70. North-Holland.Google ScholarGoogle Scholar
  33. Michie, Donald. 1968. "Memo" functions and machine learning. Nature 218:19--22.Google ScholarGoogle ScholarCross RefCross Ref
  34. MonadPlus. 2008. MonadPlus. http://www.haskell.org/haskellwiki/MonadPlus.Google ScholarGoogle Scholar
  35. Morrisett, J. Gregory. 1993. Refining first-class stores. In Proceedings of the workshop on state in programming languages.Google ScholarGoogle Scholar
  36. Naylor, Matthew, Emil Axelsson, and Colin Runciman. 2007. A functional-logic library for Wired. In Haskell workshop, 37--48. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. Nicollet, Victor, et al. 2009. Lazy and threads. http://caml.inria.fr/pub/ml-archives/caml-list/2009/02/9fc4e4a897ce7a356674660c8cfa5ac0.fr.html.Google ScholarGoogle Scholar
  38. Nordin, Thomas, and Andrew Tolmach. 2001. Modular lazy search for constraint satisfaction problems. JFP 11(5):557--587. Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. Rabin, Michael O., and Dana Scott. 1959. Finite automata and their decision problems. IBM Journal of Research and Development 3:114--125.Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. Runciman, Colin, Matthew Naylor, and Fredrik Lindblad. 2008.Google ScholarGoogle Scholar
  41. SmallCheck and Lazy SmallCheck: Automatic exhaustive testing for small values. In Haskell symposium, 37--48. Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. Seaman, Jill M. 1993. An operational semantics of lazy evaluation for analysis. Ph.D. thesis, Pennsylvania State University. Google ScholarGoogle ScholarDigital LibraryDigital Library
  43. Spivey, J. Michael. 2000. Combinators for breadth-first search. JFP 10(4):397--408. Google ScholarGoogle ScholarDigital LibraryDigital Library
  44. Tolmach, Andrew, and Sergio Antoy. 2003. A monadic semantics for core Curry. In WFLP, 33--46. Valencia, Spain.Google ScholarGoogle Scholar
  45. Tolmach, Andrew, Sergio Antoy, and Marius Nita. 2004. Implementing functional logic languages using multiple threads and stores. In ICFP, 90--102. Google ScholarGoogle ScholarDigital LibraryDigital Library
  46. de Vries, Edsko. 2009. Just how unsafe is unsafe. http://www.haskell.org/pipermail/haskell-cafe/2009-February/055201.html.Google ScholarGoogle Scholar
  47. 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 ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Purely functional lazy non-deterministic programming

          Recommendations

          Comments

          Login options

          Check if you have access through your login credentials or your institution to get full access on this article.

          Sign in

          Full Access

          • Published in

            cover image ACM SIGPLAN Notices
            ACM SIGPLAN Notices  Volume 44, Issue 9
            ICFP '09
            September 2009
            343 pages
            ISSN:0362-1340
            EISSN:1558-1160
            DOI:10.1145/1631687
            Issue’s Table of Contents
            • cover image ACM Conferences
              ICFP '09: Proceedings of the 14th ACM SIGPLAN international conference on Functional programming
              August 2009
              364 pages
              ISBN:9781605583327
              DOI:10.1145/1596550

            Copyright © 2009 ACM

            Publisher

            Association for Computing Machinery

            New York, NY, United States

            Publication History

            • Published: 31 August 2009

            Check for updates

            Qualifiers

            • research-article

          PDF Format

          View or Download as a PDF file.

          PDF

          eReader

          View online with eReader.

          eReader
          About Cookies On This Site

          We use cookies to ensure that we give you the best experience on our website.

          Learn more

          Got it!