Bimonadic Semantics for Basic Pattern Matching Calculi

  • Wolfram Kahl
  • Jacques Carette
  • Xiaoheng Ji
Part of the Lecture Notes in Computer Science book series (LNCS, volume 4014)


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.


Pattern Match Type Semantic Reduction Rule Syntactic Category Denotational Semantic 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Barr, M., Wells, C.: Category Theory for Computing Science, 3rd edn. Centre de recherches mathématiques (CRM), Université de Montréal (1999)Google Scholar
  2. 2.
    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)CrossRefGoogle Scholar
  3. 3.
    Carette, J.: Gaussian elimination: a case study in efficient genericity with MetaOCaml. Sci. of Comput. Program (to appear)Google Scholar
  4. 4.
    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)Google Scholar
  5. 5.
    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)Google Scholar
  6. 6.
    Hanus, M., et al.: Curry—an integrated functional logic language, version 0.8.2 (2006),
  7. 7.
    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)CrossRefGoogle Scholar
  8. 8.
    Harrison, W.L., Kieburtz, R.B.: The logic of demand in Haskell. J. of Funct. Program. 15(6), 837–891 (2005)MATHCrossRefMathSciNetGoogle Scholar
  9. 9.
    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)Google Scholar
  10. 10.
    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:
  11. 11.
    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)CrossRefGoogle Scholar
  12. 12.
    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)Google Scholar
  13. 13.
    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)Google Scholar
  14. 14.
    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)CrossRefGoogle Scholar
  15. 15.
    Moggi, E.: Notions of computation and monads. Inform. and Comput. 93, 55–92 (1991)MATHCrossRefMathSciNetGoogle Scholar
  16. 16.
    Peyton Jones, S., et al.: The Revised Haskell 1998 Report. Cambridge Univ. Press, Cambridge (2003), Also available from: Google Scholar
  17. 17.
    Plasmeijer, R., van Eekelen, M.: Functional Programming and Parallel Graph Rewriting. Int. Computer Science Series. Addison-Wesley, Reading (1993)MATHGoogle Scholar
  18. 18.
    Tucker, J.V., Zucker, J.I.: Abstract versus concrete computation on metric partial algebras. ACM Trans. Comput. Logic 5(4), 611–668 (2004)CrossRefMathSciNetGoogle Scholar
  19. 19.
    Tullsen, M.: First class patterns. In: Pontelli, E., Santos Costa, V. (eds.) PADL 2000. LNCS, vol. 1753, pp. 1–15. Springer, Heidelberg (2000)CrossRefGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2006

Authors and Affiliations

  • Wolfram Kahl
    • 1
  • Jacques Carette
    • 1
  • Xiaoheng Ji
    • 1
  1. 1.Department of Computing and SoftwareMcMaster UniversityHamilton, OntarioCanada

Personalised recommendations