Abstract
The pattern matching calculi introduced by the first author are a refinement of the λ-calculus that integrates mechanisms appropriate for fine-grained modelling of non-strict pattern matching.
While related work in the literature only uses a single monad, typically Maybe, for matchings, we present an axiomatic approach to semantics of these pattern matching calculi using two monads, one for expressions and one for matchings.
Although these two monads only need to be relatively lightly coupled, this semantics implies soundness of all core PMC rules, and is a useful tool for exploration of the design space for pattern matching calculi.
Using lifting and Maybe monads, we obtain standard Haskell semantics, and by adding another level of Maybe to both, we obtain a denotational semantics of the “matching failure as exceptions” approach of Erwig and Peyton Jones. Using list-like monads opens up interesting extensions in the direction of functional-logic programming.
Preview
Unable to display preview. Download preview PDF.
Similar content being viewed by others
References
Barr, M., Wells, C.: Category Theory for Computing Science, 3rd edn. Centre de recherches mathématiques (CRM), Université de Montréal (1999)
Carette, J., Kiselyov, O.: Multi-stage programming with functors and monads: eliminating abstraction overhead from generic code. In: Glück, R., Lowry, M. (eds.) GPCE 2005. LNCS, vol. 3676, pp. 256–274. Springer, Heidelberg (2005)
Carette, J.: Gaussian elimination: a case study in efficient genericity with MetaOCaml. Sci. of Comput. Program (to appear)
Erwig, M., Peyton Jones, S.: Pattern guards and transformational patterns. In: Proc. of 2000 ACM SIGPLAN Haskell Wksh., Haskell 2000. Electron. Notes in Theor. Comput. Sci., vol. 41(1), p. 27 (2001)
Hanus, M.: A unified computation model for declarative programming. In: Proc. of 1997 APPIA-GULP-PRODE Joint Conf. on Declarative Programming, pp. 9–24 (1997)
Hanus, M., et al.: Curry—an integrated functional logic language, version 0.8.2 (2006), http://www.informatik.uni-kiel.de/~curry/report.html
Harrison, W.L., Sheard, T., Hook, J.: Fine control of demand in Haskell. In: Boiten, E.A., Möller, B. (eds.) MPC 2002. LNCS, vol. 2386, pp. 68–93. Springer, Heidelberg (2002)
Harrison, W.L., Kieburtz, R.B.: The logic of demand in Haskell. J. of Funct. Program. 15(6), 837–891 (2005)
Jung, A., Fiore, M., Moggi, E., O’Hearn, P., Riecke, J., Rosolini, G., Stark, I.: Domains and denotational semantics: history, accomplishments and open problems. Bull. of EATCS 59, 227–256 (1996)
Kahl, W., Carette, J., Ji, X.: Bimonadic semantics for basic pattern matching calculi. SQRL Report 33. Software Quality Research Laboratory, McMaster Univ. (2003), Available from: http://sqrl.mcmaster.ca/sqrl_reports.html
Kahl, W.: Basic pattern matching calculi: a fresh view on matching failure. In: Kameyama, Y., Stuckey, P.J. (eds.) FLOPS 2004. LNCS, vol. 2998, pp. 276–290. Springer, Heidelberg (2004)
Kiselyov, O., Shan, C.-c., Friedman, D.P., Sabry, A.: Backtracking, interleaving, and terminating monad transformers. In: Proc. of 10th Int. Conf. on Functional Programming, ICFP 2005, pp. 192–203. ACM Press, New York (2005)
Lüth, C., Ghani, N.: Composing monads using coproducts. In: Proc. of 7th Int. Conf. on Functional Programming, ICFP 2002, pp. 133–144. ACM Press, New York (2002)
Moggi, E.: A modular approach to denotational semantics. In: Curien, P.-L., Pitt, D.H., Pitts, A.M., Poigné, A., Rydeheard, D.E., Abramsky, S. (eds.) CTCS 1991. LNCS, vol. 530, pp. 138–139. Springer, Heidelberg (1991)
Moggi, E.: Notions of computation and monads. Inform. and Comput. 93, 55–92 (1991)
Peyton Jones, S., et al.: The Revised Haskell 1998 Report. Cambridge Univ. Press, Cambridge (2003), Also available from: http://haskell.org/
Plasmeijer, R., van Eekelen, M.: Functional Programming and Parallel Graph Rewriting. Int. Computer Science Series. Addison-Wesley, Reading (1993)
Tucker, J.V., Zucker, J.I.: Abstract versus concrete computation on metric partial algebras. ACM Trans. Comput. Logic 5(4), 611–668 (2004)
Tullsen, M.: First class patterns. In: Pontelli, E., Santos Costa, V. (eds.) PADL 2000. LNCS, vol. 1753, pp. 1–15. Springer, Heidelberg (2000)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2006 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Kahl, W., Carette, J., Ji, X. (2006). Bimonadic Semantics for Basic Pattern Matching Calculi. In: Uustalu, T. (eds) Mathematics of Program Construction. MPC 2006. Lecture Notes in Computer Science, vol 4014. Springer, Berlin, Heidelberg. https://doi.org/10.1007/11783596_16
Download citation
DOI: https://doi.org/10.1007/11783596_16
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-35631-8
Online ISBN: 978-3-540-35632-5
eBook Packages: Computer ScienceComputer Science (R0)