Skip to main content

First Class Patterns?

  • Conference paper
  • First Online:
Practical Aspects of Declarative Languages (PADL 2000)

Part of the book series: Lecture Notes in Computer Science ((LNCS,volume 1753))

Included in the following conference series:

Abstract

Pattern matching is a great convenience in programming. However, pattern matching has its problems: it conflicts with data abstraction; it is complex (at least in Haskell, which has pattern guards, irrefutable patterns, n+k patterns, as patterns, etc.); it is a source of runtime errors; and lastly, one cannot abstract over patterns as they are not a first class language construct. This paper proposes a simplification of pattern matching that makes patterns first class. The key idea is to treat patterns as functions of type “a→Maybe b”|i.e., “a→(Nothing|Just b)”; thus, patterns and pattern combinators can be written as functions in the language.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. William Aitken and John H. Reppy. Abstract value constructors: Symbolic constants for standard ML. Technical Report CORNELLCS//TR92-1290, Cornell University, Computer Science Department, June 1992.

    Google Scholar 

  2. F. W. Burton and R. D. Cameron. Pattern matching with abstract data types. Journal of Functional Programming, 3(2):171–190, 1993.

    Article  MathSciNet  Google Scholar 

  3. Manuel Fähndrich and John Boyland. Statically checkable pattern abstractions. In Proceedings of the 1997 ACM SIGPLAN International Conference on Functional Programming, pages 75–84, Amsterdam, The Netherlands, 9–11 June 1997.

    Google Scholar 

  4. P. Hudak, S. P. Jones, and P. Wadler. Report on the programming language Haskell. SIGPLAN Notices, 27(5), May 1992.

    Google Scholar 

  5. Graham Hutton and Erik Meijer. Monadic parser combinators. Technical Report NOTTCS-TR-96-4, University of Nottingham, December 1996.

    Google Scholar 

  6. John Hughes. Generalizing monads to arrows. Submitted for publication, 1998.

    Google Scholar 

  7. Palao Gostanza Pedro, Ricardo Peña, and Manuel Núñez. A new look at pattern matching in abstract data types. In Proceedings of the ACM SIG-PLAN International Conference on Functional Programming (ICFP’ 96), volume 31(6) of ACM SIGPLAN Notices, pages 110–121. ACM, June 1996.

    Article  Google Scholar 

  8. P. L. Wadler. How to replace failure by a list of successes. In Jean-Pierre Jouannaud, editor, Functional Programming Languages and Computer Architecture, volume 201 of Lecture Notes in Computer Science, pages 113–128. Springer Verlag, September 1985.

    Google Scholar 

  9. Philip Wadler. Efficient compilation of pattern-matching. In S. L. Peyton Jones, editor, The Implementation of Functional Programming Languages, chapter 5. Prentice-Hall International, 1987.

    Google Scholar 

  10. Philip Wadler. Views: A way for pattern-matching to cohabit with data abstraction. In Conference Record of the Fourteenth Annual ACM Symposium on Principles of Programming Languages, pages 307–313. ACM, January 1987.

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 1999 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Tullsen, M. (1999). First Class Patterns?. In: Pontelli, E., Santos Costa, V. (eds) Practical Aspects of Declarative Languages. PADL 2000. Lecture Notes in Computer Science, vol 1753. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-46584-7_1

Download citation

  • DOI: https://doi.org/10.1007/3-540-46584-7_1

  • Published:

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-66992-0

  • Online ISBN: 978-3-540-46584-3

  • eBook Packages: Springer Book Archive

Publish with us

Policies and ethics