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.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
Similar content being viewed by others
References
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.
F. W. Burton and R. D. Cameron. Pattern matching with abstract data types. Journal of Functional Programming, 3(2):171–190, 1993.
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.
P. Hudak, S. P. Jones, and P. Wadler. Report on the programming language Haskell. SIGPLAN Notices, 27(5), May 1992.
Graham Hutton and Erik Meijer. Monadic parser combinators. Technical Report NOTTCS-TR-96-4, University of Nottingham, December 1996.
John Hughes. Generalizing monads to arrows. Submitted for publication, 1998.
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.
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.
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.
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.
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights 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