Constructing language processors with algebra combinators

Modular Monadic Semantics (MMS) is a well-known mechanism for structuring modular denotational semantic definitions for programming languages. The principal attraction of MMS is that families of language constructs can be independently specified and later combined in a mix-and-match fashion to create a complete language semantics. This has proved useful for constructing formal, yet executable, semantics when prototyping languages. In this work we demonstrate that MMS has an additional software engineering benefit. Rather than composing semantics for various language constructs, we can use MMS to compose various differing semantics for the same language constructs. We describe algebra combinators, the principal vehicle for achieving this reuse, along with a series of applications of the technique for common language processing tasks.

[1]  Philip Wadler Monads for Functional Programming , 1995, Advanced Functional Programming.

[2]  Perry Alexander System Level Design with Rosetta , 2006 .

[3]  Graham Hutton,et al.  Fold and unfold for program semantics , 1998, ICFP '98.

[4]  Eelco Visser,et al.  Stratego: A Language for Program Transformation Based on Rewriting Strategies , 2001, RTA.

[5]  Paul Hudak,et al.  Monad transformers and modular interpreters , 1995, POPL '95.

[6]  Johan Jeuring,et al.  PolyP—a polytypic programming language extension , 1997, POPL '97.

[7]  Ralf Lämmel,et al.  Typed Combinators for Generic Traversal , 2002, PADL.

[8]  Simon Peyton Jones,et al.  Tackling the Awkward Squad: monadic input/output, concurrency, exceptions, and foreign-language calls in Haskell , 2005 .

[9]  Matthias Felleisen,et al.  The Denotational Specifications of Complex Languages , 2005 .

[10]  Mark P. Jones,et al.  Type Classes with Functional Dependencies , 2000, ESOP.

[11]  Gérard P. Huet,et al.  The Zipper , 1997, Journal of Functional Programming.

[12]  Paul Hudak,et al.  Modular Denotational Semantics for Compiler Construction , 1996, ESOP.

[13]  Guy L. Steele,et al.  Building interpreters by composing monads , 1994, POPL '94.

[14]  Johan Jeuring,et al.  Advanced Functional Programming, First International Spring School on Advanced Functional Programming Techniques-Tutorial Text , 1995 .

[15]  Ralf Lämmel,et al.  Design patterns for functional strategic programming , 2002, RULE '02.

[16]  Simon L. Peyton Jones,et al.  Scrap your boilerplate: a practical design pattern for generic programming , 2003, TLDI '03.

[17]  Alan Bawden,et al.  Quasiquotation in Lisp , 1999, PEPM.

[18]  Peyton Jones,et al.  Haskell 98 language and libraries : the revised report , 2003 .

[19]  J. E. Labra Gayo,et al.  LPS: A Language Prototyping System Using Modular Monadic Semantics , 2001, LDTA@ETAPS.

[20]  Ralf Lämmel,et al.  A Strafunski Application Letter , 2003, PADL.

[21]  Samuel N. Kamin,et al.  Metacomputation-Based Compiler Architecture , 2000, MPC.

[22]  David A. Espinosa Semantic Lego , 1995 .

[23]  Conor McBride,et al.  Applicative programming with effects , 2008, J. Funct. Program..

[24]  Grant Malcolm,et al.  Algebraic Data Types and Program Transformation , 1990 .

[25]  Simon L. Peyton Jones,et al.  Scrap more boilerplate: reflection, zips, and generalised casts , 2004, ICFP '04.

[26]  Maarten M. Fokkinga,et al.  Functional Programming with Bananas, Lenses, Envelopes and Barbed Wire , 1991, FPCA.

[27]  Emir Pasalic,et al.  Two-level types and parameterized modules , 2004, Journal of Functional Programming.

[28]  Ralf Lämmel,et al.  Dealing with large bananas , 2000 .

[29]  Philip Wadler,et al.  Comprehending monads , 1990, LISP and Functional Programming.

[30]  Simon L. Peyton Jones,et al.  Associated types with class , 2005, POPL '05.

[31]  Johan Jeuring,et al.  Merging Monads and Folds for Functional Programming , 1995, Advanced Functional Programming.

[32]  Eugenio Moggi,et al.  Notions of Computation and Monads , 1991, Inf. Comput..

[33]  Tim Sheard A type-directed, on-line, partial evaluator for a polymorphic language , 1997 .