How to replace failure by a list of successes a method for exception handling, backtracking, and pattern matching in lazy functional languages

  • Philip Wadler
Conference paper

DOI: 10.1007/3-540-15975-4_33

Volume 201 of the book series Lecture Notes in Computer Science (LNCS)
Cite this paper as:
Wadler P. (1985) How to replace failure by a list of successes a method for exception handling, backtracking, and pattern matching in lazy functional languages. In: Jouannaud JP. (eds) Functional Programming Languages and Computer Architecture. FPCA 1985. Lecture Notes in Computer Science, vol 201. Springer, Berlin, Heidelberg

Abstract

Should special features for exception handling, backtracking, or pattern matching be included in a programming language? This paper presents a method whereby some programs that use these features can be re-written in a functional language with lazy evaluation, without the use of any special features. This method may be of use for practicing functional programmers; in addition, it provides further evidence of the power of lazy evaluation. The method itself is straightforward: each term that may raise an exception or backtrack is replaced by a term that returns a list of values. In the special case of pattern matching without backtracking, the method can be applied even if lazy evaluation is not present. The method should be suitable for applications such as theorem proving using tacticals, as in ML/LCF.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Copyright information

© Springer-Verlag 1985

Authors and Affiliations

  • Philip Wadler
    • 1
  1. 1.Programming Research GroupOxford UniversityOxford