Modular development of interpreters from semantic building blocks
José Emilio Labra Gayo, Juan Manuel Cueva Lovelle, María Cándida Luengo Díez, Agustín Cernuda del Río · Nordic journal of computing · 2001
We present an integration of modular monadic semantics and generic programming concepts that facilitates the modular development of interpreters. Using modular monadic semantics, the computational structure is obtained as the composition of several monad transformers where each monad transformer adds a new notion of computation. Using generic programming, it is possible to divide the recursive structure of the abstract syntax in several non-recursive pattern functors. For each functor F, it is possible to define an F-algebra over the computational structure. In this way, an interpreter is automatically obtained as a catamorphism.In this paper we show that it is also possible to use monadic catamorphisms and to combine them with catamorphisms allowing the separation between recursive evaluation from semantic specification. As an example, we define the modular specification of a simple functional programming language with imperative features.