Presented at Haskell Symposium 2022: https://icfp22.sigplan.org/home/haskellsymp-2022
Paper: https://dl.acm.org/doi/10.1145/3546189.3549917
Artefact: https://github.com/tmcdonell/embedded-pattern-matching/
Video: https://youtu.be/Y1s28Sm5s8E
Haskell is a popular choice for hosting deeply embedded languages. A recurring challenge for these embeddings is how to seamlessly integrate user defined algebraic data types. In particular, one important, convenient, and expressive feature for creating and inspecting data—pattern matching—is not directly available on embedded terms. In this paper, we present a novel technique, embedded pattern matching, which enables a natural and user friendly embedding of user defined algebraic data types into the embedded language. Our technique enables users to pattern match on terms in the embedded language in much the same way they would in the host language.