Wolfram Kahl, Jacques Carette, Xiaoheng Ji
SQRL Report No. 33
32 pages
Software Quality Research Laboratory
Department of Computing and Software
McMaster University
June 2006
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.
A short version of this report appeared as [Kahl-Carette-Ji-2006a], in the proceedings of MPC 2006.