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. 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, and allows programmers to pattern match on terms in the embedded language in much the same way they would in the host language.
翻译:Haskell 是容纳深嵌语言的流行选择。 这些嵌入的经常性挑战是如何无缝地整合用户定义的代数数据类型。 特别是, 创建和检查数据的一个重要、 方便和直观的功能 -- -- 模式匹配 -- -- 无法直接以嵌入的术语提供。 我们展示了一种新的技术, 嵌入模式匹配, 使用户定义的代数数据类型能够自然地和方便地嵌入嵌入语言, 使程序员能够以与主用语言大致相同的方式, 以嵌入语言对内嵌语言的术语进行匹配。