Skip to main content Accessibility help
×
×
Home

Purely functional lazy nondeterministic programming

  • SEBASTIAN FISCHER, OLEG KISELYOV and CHUNG-CHIEH SHAN
Abstract

Functional 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 because the existing features for nonstrictness, sharing, and nondeterminism in functional languages are tricky to combine. We present a practical way to write purely functional lazy nondeterministic 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 nondeterministic components, by working with custom monadic data types and search strategies, and by providing equational laws for the programmer to reason about their code.

Copyright
Corresponding author
(e-mail: oleg@okmij.org)
References
Hide All
Acosta-Gómez, A. (2007) Hardware Synthesis in ForSyDe. Master's thesis, Stockholm, Sweden: Department of Microelectronics and Information Technology, Royal Institute of Technology.
Albert, E., Hanus, M., Huch, F., Oliver, J. & Vidal, G. (2005) Operational semantics for declarative multi-paradigm languages. J. Symb. Comput. 40 (1), 795829.
Antoy, S. & Hanus, M. (2002) Functional logic design patterns. In Proceedings of Symposium on Functional and Logic Programming (FLOPS), pp. 67–87.
Antoy, S. & Hanus, M. (2006) Overlapping rules and logic variables in functional logic programs. In Proceedings of International Conference on Logic Programming, pp. 87–101.
Ariola, Z. M. & Felleisen, M. (1997) The call-by-need lambda calculus. J. Funct. Program. 7 (3), 265301.
Ariola, Z. M., Felleisen, M., Maraist, J., Odersky, M. & Wadler, P. (1995) The call-by-need lambda calculus. In Proceedings of Symposium on Principles of Programming Languages (POPL), pp. 233–246.
Bird, R., Jones, G. & de Moor, O. (1997) More haste, less speed: Lazy versus eager evaluation. J. Funct. Program. 7 (5), 541–547.
Bjesse, P., Claessen, K., Sheeran, M. & Singh, S. (1998) Lava: Hardware design in Haskell. In Proceedings of International Conference on Functional Programming (ICFP), pp. 174–184.
Braßel, B. & Huch, F. (2007) On a tighter integration of functional and logic programming. In Proceedings of Asian Symposium on Programming Languages and Systems (APLAS), Shao, Z. (ed), LNCS, vol. 4807, Berlin: Springer, pp. 122138.
Braßl, B. & Huch, F. (2009) The Kiel Curry System KiCS. In Proceedings of Workshop on Logic Programming (WLP), 195–205.
Christiansen, J. & Fischer, S. (2008) EasyCheck—Test data for free. In Proceedings of Symposium on Functional and Logic Programming (FLOPS), pp. 322–336.
Claessen, K. (2004) Parallel parsing processes. J. Funct. Program. 14 (6), 741757.
Claessen, K. & Hughes, J. (2000). QuickCheck: A lightweight tool for random testing of Haskell programs. In Proceedings of International Conference on Functional Programming (ICFP), pp. 268–279.
Escardó, M. H. (2007) Infinite sets that admit fast exhaustive search. In Proceedings of IEEE Symposium on Logic in Computer Science (LICS), pp. 443–452.
Felleisen, M. (1985) Transliterating Prolog into Scheme. Technical Report 182. Computer Science Department, Indiana University.
Filinski, A. (1999) Representing layered monads. In Proceedings of Symposium on Principles of Programming Languages (POPL), pp. 175–188.
Fischer, S. & Kuchen, H. (2007) Systematic generation of glass-box test cases for functional logic programs. In Proceedings of Principles and Practice of Declarative Programming (PPDP), pp. 63–74.
Garcia, R., Lumsdaine, A. & Sabry, A. (2009) Lazy evaluation & delimited control. In Proceedings of Symposium on Principles of Programming Languages (POPL), pp. 153–164.
González-Moreno, J. C., Hortalá-González, M. T., López-Fraguas, F. J. & Rodríguez-Artalejo, M. (1999) An approach to declarative programming based on a rewriting logic. J. Log. Program. 40 (1), 4787.
Goodman, N., Mansinghka, V. K., Roy, D., Bonawitz, K. & Tenenbaum, J. B. (2008). Church: A language for generative models. In Proceedings of Conference on Uncertainty in Artificial Intelligence, pp. 220–229.
Haynes, C. T. (1987) Logic continuations. J. Log. Prog. 4 (2), 157176.
Hinze, R. (2000) Deriving backtracking monad transformers (functional pearl). In Proceedings of International Conference on Functional Programming (ICFP), pp. 186–197.
Hudak, P. (1996) Building domain-specific embedded languages. ACM Comput. Surv. 28 (4es): 196.
Hughes, J. (1989) Why functional programming matters. Comput. J. 32 (2), 98107.
Kiselyov, O. & Shan, C. (2009) Embedded probabilistic programming. In Proceedings of the Working Conference on Domain-Specific Languages, pp. 360–384.
Kiselyov, O., Shan, C., Friedman, D. P. & Sabry, A. (2005) Backtracking, interleaving, and terminating monad transformers (functional pearl). In Proceedings of International Conference on Functional Programming (ICFP), pp. 192–203.
Kitchin, D., Quark, A., Cook, W. R. & Misra, J. (2009) The Orc programming language. In Proceedings of FMOODS 2009 and FORTE 2009 (Formal Techniques for Distributed Systems), Lee, D., Lopes, A. & Poetzsch-Heffter, A. (eds), LNCS 5522. Berlin: Springer, pp. 125.
Koller, D., McAllester, D. & Pfeffer, A. (1997) Effective Bayesian inference for stochastic programs. In Proceedings of National Conference on Artificial Intelligence (AAAI), pp. 740–747.
Launchbury, J. (1993) A natural semantics for lazy evaluation. In Proceedings of Symposium on Principles of Programming Languages (POPL), pp. 144–154.
Launchbury, J. & Elliott, T. (2010) Concurrent orchestration in Haskell. In Haskell Symposium, Gibbons, J. (ed). ACM Press, pp. 7990.
Launchbury, J. & Peyton Jones, S. L. (1994) Lazy functional state threads. In Proceedings of Conference on Programming Language Design and Implementation (PLDI). ACM Press, pp. 2435.
López-Fraguas, F. J., Rodríguez-Hortalá, J. & Sánchez-Hernández, J. (2007) A simple rewrite notion for call-time choice semantics. In Proceedings of Principles and Practice of Declarative Programming (PPDP), pp. 197–208.
López-Fraguas, F. J., Rodríguez-Hortalá, J. & Sánchez-Hernández, J. (2008) Rewriting and call-time choice: The HO case. In Proceedings of Symposium on Functional and Logic Programming (FLOPS), pp. 147–162.
Maraist, J., Odersky, M. & Wadler, P. (1998) The call-by-need lambda calculus. J. Funct. Program. 8 (3), 275317.
McCarthy, J. (1963) A basis for a mathematical theory of computation. In Proceedings of Computer Programming and Formal Systems. North-Holland, pp. 3370.
Michie, D. (1968) “Memo” functions and machine learning. Nature 218, 1922.
Moggi, E. (1989) Computational lambda-calculus and monads. In Proceedings of Logic in Computer Science (LICS). Piscataway, NJ, USA: IEEE Press, pp. 1423.
MonadPlus. (2008) MonadPlus. http://www.haskell.org/haskellwiki/MonadPlus.
Morrisett, J. G. (1993) Refining first-class stores. In Proceedings of the Workshop on State in Programming Languages, pp. 73–87.
Naylor, M., Axelsson, E. & Runciman, C. (2007) A functional-logic library for Wired. In Proceedings of Haskell Workshop, pp. 37–48.
Peyton Jones, S. L., Reid, A., Hoare, T., Marlow, S. & Henderson, F. (1999) A semantics for imprecise exceptions. In Proceedings of Conference on Programming Language Design and Implementation (PLDI). ACM Press, pp. 2536.
Rabin, M. O. & Scott, D. (1959) Finite automata and their decision problems. IBM J. Res. Dev. 3, 114125.
Runciman, C., Naylor, M. & Lindblad, F. (2008) SmallCheck and Lazy SmallCheck: Automatic exhaustive testing for small values. In Proceedings of Haskell Symposium, pp. 37–48.
Seaman, J. M. (1993) An Operational Semantics of Lazy Evaluation for Analysis. PhD. thesis. Pennsylvania State University.
Spivey, J. M. (2000) Combinators for breadth-first search. J. Funct. Program. 10 (4), 397408.
Tolmach, A. & Antoy, S. (2003) A monadic semantics for core Curry. In Proceedings of Workshop on Functional and Logic Programming (WFLP), Valencia, Spain, pp. 3346.
Tolmach, A., Antoy, S. & Nita, M. (2004) Implementing functional logic languages using multiple threads and stores. In Proceedings of International Conference on Functional Programming (ICFP), pp. 90–102.
de Vries, E. (2009) Just how unsafe is unsafe. http://www.haskell.org/pipermail/haskell-cafe/2009-February/055201.html.
Wadler, P. 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 Proceedings of Functional Programming Languages and Computer Architecture, pp. 113–128.
Wadler, P. L. (1992) The essence of functional programming. In Proceedings of Symposium on Principles of Programming Languages (POPL). ACM Press, pp. 114.
Recommend this journal

Email your librarian or administrator to recommend adding this journal to your organisation's collection.

Journal of Functional Programming
  • ISSN: 0956-7968
  • EISSN: 1469-7653
  • URL: /core/journals/journal-of-functional-programming
Please enter your name
Please enter a valid email address
Who would you like to send this to? *
×

Metrics

Full text views

Total number of HTML views: 0
Total number of PDF views: 0 *
Loading metrics...

Abstract views

Total abstract views: 0 *
Loading metrics...

* Views captured on Cambridge Core between <date>. This data will be updated every 24 hours.

Usage data cannot currently be displayed

Purely functional lazy nondeterministic programming

  • SEBASTIAN FISCHER, OLEG KISELYOV and CHUNG-CHIEH SHAN
Submit a response

Discussions

No Discussions have been published for this article.

×

Reply to: Submit a response


Your details


Conflicting interests

Do you have any conflicting interests? *