### A Language Prototyping Tool based on

### Semantic Building Blocks

J. E. Labra Gayo, J. M. Cueva Lovelle, M. C. Luengo D´ıez, and B. M. Gonz´alez Rodr´ıguez Department of Computer Science, University of Oviedo

C/ Calvo Sotelo S/N, 3307, Oviedo, Spain {labra,cueva,candi,martin}@lsi.uniovi.es

Abstract. We present a Language Prototyping System that facilitates the modular development of interpreters from semantic specifications. The theoretical basis of our system is the integration of ideas from generic programming and modular monadic semantics. The system is implemented as a domain-specific language embedded in Haskell and contains an interactive framework for language prototyping.

In the monadic approach, the semantic spscification of a programming language is captured as a functionΣ→M VwhereΣ represents the ab-stract syntax,Mthe computational monad, andVthe domain value. In order to obtain more extensibility, we use folds or catamorphisms over the fixpoint of non-recursive pattern functors that capture the structure of the abstract syntax. For each pattern functorF, the semantic spec-ifications are defined as independent F-Algebras whose carrier is M V, whereM is the computational monad andV models the domain value. The copmputational monadM can itself be obtained from the compo-sition of several monad transformers applied to a base monad, and the domain valueVcan be defined using extensible union types.

In this paper, we also show that when the abstract syntax contains sev-eral categories, it is possible to define many-sorted algebras obtaining the same modularity.

### 1

### Introduction

E. Moggi [39] applied monads to denotational semantics in order to capture the notion of computation and the intuitive idea of separating computations from values.

After his work, there was some interest in the development of modular in-terpreters using monads [49,43,10]. The problem was that, in general, it is not possible to compose two monads to obtain a new monad [25]. A proposed solution was the use of monad transformers [33,32] which transform a given monad into a new one adding new operations. This approach was called modular monadic semantics.

In a different context, the definition of recursive datatypes as least fixpoints of pattern functors and the calculating properties that can be obtained be means

of folds or catamorphisms led to a complete discipline which could be named as generic programming [3,34,35].

In [9], L. Duponcheel proposed the combined use of folds or catamorphisms with modular monadic semantics allowing the independent specification of the abstract syntax, the computational monad and the domain value.

Following [36], we applied monadic folds to modular monadic semantics allowing the separation between recursive evaluation and semantic specifica-tion [28,29,30].

In practice, the abstract syntax is usually formed fromn mutually recursive categories, In this paper we show how we can extend our previous work to handle many-sorted algebras.

The paper is organized as follows. In section 2 we give an informal presenta-tion of modular monadic semantics defining some monad transformers. Secpresenta-tion 3 presents the basic concepts from generic programming extending previous work to handle many-sorted algebras. In section 4 we specify the semantics of a simple imperative programming language from reusable components.

Along the paper, we use Haskell syntax with some freedom in the use of mathematical operators and datatype declarations. As an example, the prede-fined datatype

dataEither a b = Left a | Right b could be defined with our notation as

αkβ _{,} Lα | Rβ

We also omit the type constructors in some definitions for brevity. The no-tions we use from category theory are defined in the paper, so it is not a prereq-uisite.

### 2

### Modular Monadic Semantics

A monadMcaptures the intuitive notion of computation. In this way, the type

Mαrepresents a computation the returns a value of typeα

In functional programming, a monad can be defined as a type constructorM

with 2 operations return :α → Mα

(=) :Mα → (α → Mβ) → Mβ

which satisfy a number of laws (see [47,49,48]). Example 1. The simplest monad is the identity monad

Idα _{,}α
return =λx →x
m=f =f x

In the rest of the paper, we will use thedo-notation defined as: do{m; e} ≡m=λ → do{e}

do{x ← m; e} ≡m=λx → do{e}

do{letexp; e} ≡letexp in do{e}

do{e} ≡e

It is possible to define monads that capture different kinds of computations, like partiality, nondeterminism, side-effects, exceptions, continuations, interac-tions, etc. [39,40,5]. Table 1 presents two classes of monads that will be used in the rest of the paper.

Table 1.Some classes of monads

Name Operations Environment AccessrdEnv:MEnv

inEnv :Env→Mα→Mα

State transformer update: (State→State)→ MState fetch:MState

set:State → MState

When describing the semantics of a programming language using monads, the main problem is the combination of different classes of monads. It is not possible to compose two monads to obtain a new monad in general [25]. Nevertheless, a monad transformerT can transform a given monad Minto a new monad T M

that has new operations and maintains the operations ofM. The idea of monad transformer is based on the notion of monad morphism that appeared in Moggi’s work [39] and was later proposed in [33]. The definition of a monad transformer is not straightforward because there can be some interactions between the in-tervening operations of the different monads. These interactions are considered in more detail in [31,32,33] and in [17] it is shown how to derive a backtracking monad transformer from its specification.

Our system contains a library of predefined monad transformers correspond-ing to each class of monad and the user can also define new monad transformers. When defining a monad transformerT over a monadM, it is necessary to specify the newreturn and (=), thelift :Mα→ T Mα operation that transforms any operation inMinto an operation in the new monadT M, and the new operations provided by the new monad. Table 2 presents the definitions of the two monad transformers that will be used in the paper.

2.1 Extensible domains

[33] defines extensible union types using multi-parameter type classes. Although we are not going to give the full details, we can assume that ifα is a subtype

Table 2.Some monad transformers with their definitions Environment reader TEnvMα , Env →Mα return x = λρ→returnx x=f = λρ→(xρ)=(λa→f aρ) lift x = λρ→x=return rdEnv = λρ→returnρ inEnvρx = λ →xρ State transformer TStateMα , State → M(α,State)

return x = λς→return(x, ς) x=f = λς→(xς)=(λ(v, ς0)→f vς0) lift x = λς→x=(λx →return(x, ς)) update f = λς→return(ς,fς) fetch = update(λς→ς) setς = update(λ →ς)

ofβ, which will be denoted asα∈β, then we have the functions ↑:α→β and

↓:β→α. We also assume thatα∈(αkβ) and thatβ ∈(αkβ).

As an example, if we define a domain of integers and booleans asIntkBool, then (↑ 3) belongs to that domain and to further extensions of it.

### 3

### Generic Programming concepts

3.1 Functors, Algebras and Catamorphisms

As in the case of monads, functors also come from category theory but can easily be defined in a functional programming setting. A functorFcan be defined as a type constructor that transforms values of typeαinto values of typeFαand a functionmapF: (α→β)→ Fα → Fβ.

The fixpoint of a functorFcan be defined as
µF _{,} In(F(µF))

In the above definition, we explicitly write the type constructorIn because we will refer to it later.

A recursive datatype can be defined as the fixpoint of a non-recursive functor that captures its shape.

Example 2. The following inductive datatype for arithmetic expressions Term
Term _{,} N Int | Term +Term | Term − Term

can be defined as the fixpoint of the functorA
Tx _{,} N Int | x +x | x − x

where themapTis1:

mapT : (α → β) → (Tα→Tβ)

mapTf (N n) =n

mapTf (x1 +x2) =f x1 +f x2 mapTf (x1 −x2) =f x1 −f x2

Once we have the shape functorT, we can obtain the recursive datatype as the fixpoint ofT

Term _{,} µT

In this way, the expression 2 + 3 can be represented as In((In(N 2)) + (In(N 3))) :Term

The sum of two functorsFand G, denoted by F⊕ Gcan be defined as
(F ⊕G)x _{,} FxkGx

wheremapF⊕G is

mapF⊕G : (α→β)→(F⊕G)α→(F⊕G)β

mapF⊕Gf (L x) = L(mapFf x)

mapF⊕Gf (R x) = R(mapGf x)

Using the sum of two functors, it is possible to extend recursive datatypes. Example 3. We can define a new pattern functor for boolean expressions

Bx = B Bool | x == x | x < x

and the composed recursive datatype of arithmetic and boolean expressions can easily be defined as

Expr _{,} µ(T ⊕ B)

Given a functor F, an F-algebra is a function ϕF:Fα → α where α is

called the carrier. An homomorphism between twoF-algebrasϕ:Fα → α and ψ:Fβ → β is a functionh:α → β which satisfies

h. ϕ = ψ .mapFh 1

In the rest of the paper we omit the definition of map functions as they can be automatically derived from the shape of the functor.

We consider a new category with F-algebras as objects and homomorphisms betweenF-algebras as morphisms. In this category,In :F(µF)→µFis an initial object, i.e. for any F-algebra ϕ : Fα → α there is a unique homomorphism ([ϕ]) :µF → αsatisfying the above equation.

([ϕ]) is called fold or catamorphism and satisfies a number of calculational properties [3,6,35,42]. It can be defined as:

([ ]) : (Fα→α)→(µF→α) ([ϕ]) (In x) =ϕ(mapF([ϕ])x)

Example 4. We can obtain a simple evaluator for arithmetic expressions defining anT-algebra whose carrier is the typemv, wheremis, in this case, any kind of monad, andInt is a subtype ofv.

ϕT : (Monadm, Int ⊆v)⇒ T(mv)→mv ϕT(Num n) = return(↑n) ϕT(e1 + e2) = do v1← e1 v2← e2 return(↑(↓v1+ ↓v2)) ϕT(e1 − e2) = do v1← e1 v2← e2 return(↑(↓v1− ↓v2))

Applying a catamorphism over ϕT we obtain the evaluation function for

terms:

evalTerm : (Monadm,Int ⊆v)⇒ Term → mv

evalTerm = ([ϕT])

The operator⊕allows to obtain a (F⊕G)-algebra from anF-algebraϕand a G-algebraψ

⊕: (Fα→α)→(Gα→α)→(F⊕G)α→α (ϕ ⊕ψ)(L x) = ϕx

(ϕ ⊕ψ)(R x) = ψx

Example 5. The above definition allows to extend the evaluator of example 4 to arithmetic and boolean expressions.

We can specify the semantics of boolean expressions with the following B -algebra

ϕB : (Monadm,Bool ⊆v)⇒ B(mv)→mv

ϕB(e1 == e2) = do v1← e1 v2← e2 return(↑(↓v1 ==↓v2)) ϕB(e1 < e2) = do v1← e1 v2← e2 return(↑(↓v1 <↓v2))

Now, the new evaluator of boolean and arithmetic expressions is automati-cally obtained as a catamorphism over the (T⊕B)-algebra.

evalExpr : (Monadm, Int ⊆v,Bool ⊆v)⇒Expr →mv

evalExpr = ([ϕT⊕ϕB])

The theory of catamorphisms can be extended to monadic catamorphisms as described in [12,19,28,30].

3.2 Many-sorted algebras and catamorphisms

The abstract syntax of a programming language is usually divided in several mutually recursive categories. It is possible to extend the previous definitions to handle many-sorted algebras. In this section, we present the theory for n= 2, but it can be defined for any number of sorts [11,37,21,41].

A bifunctor _{F} is a type constructor that assigns a type _{F}α β to a pair of
typesαandβ and an operation

bimap_{F}: (α→γ) → (β→δ) → (_{F}α β→_{F}γ δ)

The fixpoint of two bifunctorsFandGis a pair of values (µ1FG,µ2FG) that

can be defined as:

µ1FG , In1(F(µ1FG) (µ2FG))

µ2FG , In2(G(µ1FG) (µ2FG))

Given two bifunctors_{F}and_{G}, a two-sorted_{F},_{G}-algebra is a pair of functions
(ϕ, ψ) such that:

ϕ:Fα β → α

ψ:Gα β → β

whereα, βare called the carriers of the two-sorted algebra.

It is possible to define_{F},_{G}-homomorphisms and a new category where (In1,In2)
form the initial object. This allows the definition of bicatamorphisms as:

([, ])1 : (_{F}α β → α) → (_{G}α β → β) → (µ1_{FG} → α)
([ϕ, ψ])1(In1x) =ϕ(bimap_{F}([ϕ, ψ])1([ϕ, ψ])2x)

([, ])2 : (Fα β → α) → (Gα β → β) → (µ2FG → β)

([ϕ, ψ])2(In2x) =ψ(bimapG([ϕ, ψ])1([ϕ, ψ])2x)

The sum of two bifunctors F and G is a new bifunctor FG and can be

defined as:

(FG)α β , Fα βk Gα β

where thebimapoperator is

bimap_{F}_{}_{G} : (α→γ)→(β →δ)→((FG)α β→((FG)γ δ)

bimap_{F}_{}_{G}f g(L x) = L(bimap_{F}_{}_{G}f g x)
bimap_{F}_{}_{G}f g(R x) = R(bimap_{F}_{}_{G}f g x)

In order to extend two-sorted algebras, we define the operators_{}1 and 2
as:
(_{}1) : (Fα β →α)→(Gα β→α)→ (FG)α β →α
(φ1 1 φ2) (L x) = φ1x
(φ2 _{}1 φ2) (R x) = φ2x
(_{}2) : (Fα β →β)→(Gα β→β)→ (FG)α β→β
(ψ1 _{}2 ψ2) (L x) = ψ1x
(ψ2 _{}2 ψ2) (R x) = ψ2x

3.3 From functors to bifunctors

When specifying several programming languages, it is very important to be able to share common blocks and to reuse the corresponding specifications. For exam-ple, arithmetic expressions should be specified in one place and their specification should be reused between different languages.

In order to reuse specifications made using single-sorted algebras in a two-sorted framework, it is necessary to extend functors to bifunctors.

Given a functorF, we define the bifunctorsF2

1andF22as:

F21α β , Fα

F22α β , Fβ

where thebimapoperations are defined as
bimap_{F}2

1f g x =f x

bimap_{F}2

2f g x =g x

Given anF-algebra, the operators 2

1 and 22 obtain the corresponding two-sorted algebras 2 1 : (Fα→α)→F21α β→α 2 1ϕx = ϕx 2 2 : (Fβ→β)→F22α β →β 2 2ϕx = ϕx

### 4

### Specification of a simple imperative language

4.1 Abstract syntax

A typical imperative programming language can be divided in two different worlds:expressionsandcommands. In our example, the expressions will be arith-metic, boolean and variables. The abstract syntax of arithmetic and boolean expressions are captured by the functorsT andBdefined in examples 2 and 3. Variables are defined using the functorV

Vx _{,} V Name

We will define commands in two steps. Firstly, sequence and assignments are defined using the bifunctorS

Se c , c;c | String := e

Secondly, control structures (conditional and loops) are defined using the bifunctor R

Re c , If e c c | While e c

In order to define the imperative languge, we need a bifunctor that represents the shape of expressions and another one representing commands. The bifunctor of expressions can be defined as an extension of the functor obtained as the sum ofT,BandV

E , (T⊕B⊕V)21

The bifunctor of commands is defined as the sum of the bifunctorsSandR

C , S R

Finally, the imperative language is the fixpoint of_{E}and_{C}
Imp _{,} µ2E R

4.2 Computational structure

In this simple language, the computational structure needs to access the envi-ronment and to transform a global state. We will use the monad Compwhich is obtained by transforming the identity monad using the monad transformers

TState andTEnv defined in table 2.

Comp _{,} (TState.TEnv)Id

Value _{,} IntkBool

and the domain value of commands is the null type ()2 _{indicating that }
com-mands do not return any value. The state and environment are defined as:

Env _{,}Name→ Loc
State _{,}Loc → Value

whereLocrepresent memory locations. We will also use the notationς _{B}{x/v}

to represent the updated stateς which assignsv tox.

4.3 Semantic functions

The semantic specification of arithmetic and boolean expressions were defined in the examples 4 and 5. We will reuse those specifications in the imperative language. With regard to variables, theV-algebra is

ϕV : V(CompValue)→CompValue

ϕV(Var x) = do

ρ ← rdEnv ς ← fetch return(ς(ρx))

The specification of sequence and assignment is
ψ_{S} : S(CompValue) (Comp()) → Comp()

ψ_{S}(c1;c2) = do
c1
c2
ψ_{S}(x := e) = do
v ← e
ρ ← rdEnv
ς ← fetch
set(ς _{B}{ρx/v})
return()

In the same way, the specification of conditional and repetitive commands is:
ψ_{R} : R(CompValue) (Comp()) → Comp()

ψ_{R}(If e c1c2) = do
v ← e
ifvthen
c1
else
c2
2

ψ_{R}(While e c) =loop
where
loop = do
v ← e
ifvthen
do{c; loop}
else
return()

Finally, the interpreter is automatically obtained as a bicatamorphism

InterImp : Imp→Comp()

InterImp = ([21(ϕT⊕ϕB⊕ϕV), ϕS2ϕR])2

Although in the above definition we have explicitily written the particular al-gebras, it is not necessary to do so in the implementation because the overloading mechanism of Haskell allows to detect which is the corresponding algebra.

### 5

### Conclusions and future work

We have presented an integration of modular monadic semantics and generic programming concepts that allows the definition of programming languages from reusable semantic especifications.

This approach has been implemented in a Language Prototyping System which allows to share semantic building blocks and provides an interactive frame-work for language testing. The system can be considered as another example of a domain-specific language embedded in Haskell [46,26,20]. This approach has some advantages: The development is easier as we can rely on the fairly good type system of Haskell, it is possible to obtain direct access to Haskell libraries and tools, and we do not need to define a new language with its syntax, seman-tics, type system, etc. At the same time, the main disadvantages are the mix-ture of error messages from the domain-specific language and the host language, Haskell type system limitations and the Haskell dependency which impedes the development of interpreters implemented in different languages. It would be in-teresting to define an independent domain specific meta-language for semantic specifications following [5,7,38].

On the theoretical side, [17] shows how to derive a backtracking monad trans-former from its specification. That approach should be applied to other types of monad transformers and it would be interesting to define a general framework for the combination many-sorted algebras and monadic catamorphisms. It would also be fruitful to study the combination of algebras, coalgebras, monads and comonads in order to provide the semantics of interactive and object-oriented features [4,23,22,27,45].

Another line of research is the automatic derivation of compilers from the interpreters built. This line has already been started in [14,15].

With regard to the implementation, we have also made a simple version of the system using first-class polymorphism [24] and extensible records [13]. This allows the definition of monads as first class values and monad transformers as functions between monads without the need of type classes. However, this feature is still not fully implemented in current Haskell systems. Recent advances in generic programming would also improve the implementation [18,16].

At this moment, we have specified simple imperative, functional, object-oriented and logic programming languages. The specifications have been made in a modular way reusing common components of the different languages.

The original goal of our research was to develop prototypes for the abstract machines underlying the integral object-oriented operating System Oviedo3 [2] whith the aim to test new features as security, concurrency, reflectiveness and distribution [8,44].

More information on theLanguage Prototyping Systemcan be obtained at [1].

### References

1. Language Prototyping System. http://lsi.uniovi.es/~labra/LPS/LPS.html. 2. D. ´Alvarez, L. Tajes, F. ´Alvarez, M. A. D´ıaz, R. Izquierdo, and J. M. Cueva.

An object-oriented abstract machine as the substrate for an object-oriented op-erating system. In J. Bosch and S. Mitchell, editors, Object Oriented Technology ECOOP’97, J¨yvask¨yla, Finland, June 1997. Springer Verlag, LNCS 1357.

3. Roland Backhouse, Patrik Jansson, Johan Jeuring, and Lambert Meertens. Generic programming - an introduction. In S. D. Swierstra, P. R. Henriques, and J. N. Oliveira, editors,Advanced Functional Programming, volume 1608 ofLecture Notes in Computer Science. Springer, 1999.

4. L. S. Barbosa. Components as processes: An exercise in coalgebraic modeling. In S. F. Smith and C. L. Talcott, editors,FMOODS’2000 - Formal Methods for Open Object-Oriented Distributed Systems, pages 397–417, Stanford, USA, September 2000. Kluwer Academic Publishers.

5. N. Benton, J. Hughes, and E. Moggi. Monads and effects. InInternational Summer School On Applied Semantics APPSEM’2000, Caminha, Portugal, 2000.

6. R. Bird and Oege de Moor. Algebra of Programming. Prentice Hall, 1997. 7. Pietro Ceciarelli and Engenio Moggi. A syntactic approach to modularity in

de-notational semantics. In5th Biennial Meeting on Category Theory and Computer Science, volume CTCS-5. CWI Technical Report, 1993.

8. M. A. D´ıaz, D. ´Alvarez, A. Garc´ıa-Mendoza, F. ´Alvarez, L. Tajes, and J. M. Cueva. Merging capabilities with the object model of an object-oriented abstract machine. In S. Demeyer and J. Bosch, editors, Ecoop’98 Workshop on Distributed Object Security, volume 1543, pages 273–276. LNCS, 1998.

9. Luc Duponcheel. Writing modular interpreters using catamorphisms, subtypes and monad transformers. Utrecht University, 1995.

10. David Espinosa. Semantic Lego. PhD thesis, Columbia University, 1995.

11. Maarten M. Fokkinga. Law and Order in Algorithmics. PhD thesis, University of Twente, February 1992.

12. Maarten M. Fokkinga. Monadic maps and folds for arbitrary datatypes. Mem-oranda Informatica 94-28, Dept. of Computer Science, Univ. of Twente, June 1994.

13. Benedict R. Gaster and Mark P. Jones. A Polymorphic Type System for Exten-sible Records and Variants. Technical Report NOTTCS-TR-96-3, Department of Computer Science, University of Nottingham, November 1996.

14. William Harrison and Samuel Kamin. Modular compilers based on monad trans-formers. In Proceedings of the IEEE International Conference on Computer Lan-guages, 1998.

15. William Harrison and Samuel Kamin. Compilation as metacomputation: Binding time separation in modular compilers. In5th Mathematics of Program Construction Conference, MPC2000, Ponte de Lima, Portugal, June 2000.

16. R. Hinze. A generic programming extension for Haskell. In E. Meijer, editor,

Proceedings of the 3rd Haskell Workshop, Paris, France, September 1999. The proceedings appear as a technical report of Universiteit Utrecht, UU-CS-1999-28. 17. Ralf Hinze. Deriving backtracking monad transformers. In Roland Backhouse and J. ˜N. Oliveira, editors, Proceedings of the 2000 International Conference on Functional Programming, Montreal, Canada, September 2000.

18. Ralf Hinze. A new approach to generic functional programming. InConference Record of POPL’00: The 27th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, January 2000.

19. Z. Hu and H. Iwasaki. Promotional transformation of monadic programs. In Work-shop on Functional and Logic Programming, Susono, Japan, 1995. World Scientific. 20. P. Hudak. Domain-specific languages. In Peter H. Salus, editor,Handbook of Pro-gramming Languages, volume III, Little Languages and Tools. Macmillan Technical Publishing, 1998.

21. H. Iwasaki, Z. Hu, and M. Takeichi. Towards manipulation of mutually recursive functions. In3rd. Fuji International Symposium on Functional and Logic Program-ming (FLOPS’98), Kyoto, Japan, 1998. World Scientific.

22. B. Jacobs and E. Poll. A monad for basic java semantics. In T. Rus, editor,

Algebraic Methodology and Software Technology, number 1816 in LNCS. Springer, 2000.

23. Bart Jacobs. Coalgebraic reasoning about classes in object-oriented languages. In

Coalgebraic Methods in Computer Science, number 11. Electronic Notes in Com-puter Science, 1998.

24. Mark P. Jones. First-class Polymorphism with Type Inference. In Proceedings of the Twenty Fourth Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, Paris, France, January 15-17 1997.

25. Mark P. Jones and L. Duponcheel. Composing monads. YALEU/DCS/RR 1004, Yale University, New Haven, CT, USA, 1993.

26. S. Kamin. Research on domain-specific embedded languages and program genera-tors. Electronic Notes in Theoretical Computer Science, Elsevier Press, 12, 1998. 27. Richard B. Kieburtz. Designing and implementing closed domain-specific

lan-guages. Invited talk at the Workshop on Semantics, Applications and Implemen-tation of Program Generation (SAIG), 2000.

28. J. E. Labra. An implementation of modular monadic semantics using folds and monadic folds. In Workshop on Research Themes on Functional Programming, Third International Summer School on Advanced Functional Programming, Braga - Portugal, 1998.

29. J. E. Labra, J. M. Cueva, and C. Luengo. Language prototyping using modular monadic semantics. In 3rd Latin-American Conference on Functional Program-ming, Recife - Brazil, March 1999.

30. J. E. Labra, J. M. Cueva, and M. C. Luengo. Modular development of interpreters from semantic building blocks. In The 12th Nordic Workshop on Programming Theory, Bergen, Norway, October 2000. University of Bergen.

31. Sheng Liang.Modular Monadic Semantics and Compilation. PhD thesis, Graduate School of Yale University, May 1998.

32. Sheng Liang and Paul Hudak. Modular denotational semantics for compiler con-struction. InProgramming Languages and Systems – ESOP’96, Proc. 6th European Symposium on Programming, Link¨oping, volume 1058 ofLecture Notes in Com-puter Science, pages 219–234. Springer-Verlag, 1996.

33. Sheng Liang, Paul Hudak, and Mark P. Jones. Monad transformers and modular interpreters. In22nd ACM Symposium on Principles of Programming Languages, San Francisco, CA. ACM, January 1995.

34. Grant Malcolm. Data structures and program transformation.Science of Computer Programming, 14:255–279, 1990.

35. E. Meijer, M. M. Fokkinga, and R. Paterson. Functional programming with ba-nanas, lenses, envelopes and barbed wire. In Functional Programming and Com-puter Architecture, pages 124–144. Springer-Verlag, 1991.

36. E. Meijer and J. Jeuring. Merging monads and folds for functional programming. In J. Jeuring and E. Meijer, editors, Advanced Functional Programming, Lecture Notes in Computer Science 925, pages 228–266. Springer-Verlag, 1995.

37. Erik Meijer. Calculating Compilers. PhD thesis, University of Nijmegen, February 1992.

38. E. Moggi. Metalanguages and applications. In A. M. Pitts and P. Dybjer, edi-tors,Semantics and Logics of Computation, Publications of the Newton Institute. Cambridge University Press, 1997.

39. Eugenio Moggi. An abstract view of programming languages. Technical Report ECS-LFCS-90-113, Edinburgh University, Dept. of Computer Science, June 1989. Lecture Notes for course CS 359, Stanford University.

40. Eugenio Moggi. Notions of computacion and monads. Information and Computa-tion, (93):55–92, 1991.

41. Alberto Pardo. Fusion of monadic (co)recursive programs. In Roland Back-house and Tim Sheard, editors, Proceedings Workshop on Generic Program-ming, WGP’98, Marstrand, Sweden, 18 June 1998. Dept. of Computing Science, Chalmers Univ. of Techn., and G¨oteborg Univ., June 1998.

42. Tim Sheard and Leonidas Fegaras. A fold for all seasons. In Proceedings 6th ACM SIGPLAN/SIGARCH Intl. Conf. on Functional Programming Languages and Computer Architecture, FPCA’93, Copenhagen, Denmark, 9–11 June 1993, pages 233–242. ACM, New York, 1993.

43. Guy L. Steele, Jr. Building interpreters by composing monads. In Conference record of POPL ’94, 21st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages: Portland, Oregon, January 17–21, 1994, pages 472–492, New York, USA, 1994. ACM Press.

44. L. Tajes, F. ´Alvarez, D. ´Alvarez, M. A. D´ıaz, and J.M. Cueva. A computational model for a distributed object-oriented operating system based on a reflective abstract machine. In S. Demeyer and J. Bosch, editors, Ecoop’98 Workshop on Reflective Object-Oriented Programming and Systems, volume 1543, pages 382– 383. LNCS, 1998.

45. Daniele Turi and Jan Rutten. On the foundations of final coalgebra semantics: non-well-founded sets, partial orders, metric spaces. Mathematical Structures in Computer Science, 8(5):481–540, 1998.

46. Arie van Deursen, Paul Klint, and Joost Visser. Domain-specific languages: An annotated bibliography. ACM SIGPLAN Notices, 35(6):26–36, June 2000. 47. P. Wadler. Comprehending monads. InACM Conference on Lisp and Functional

Programming, pages 61–78, Nice, France, June 1990. ACM Press.

48. P. Wadler. Monads for functional programming. Lecture notes for Marktoberdorf Summer School on Program Design Calculi, Springer-Verlag, Aug 1992.

49. P. Wadler. The essence of functional programming. InPOPL ’92, Albuquerque, 1992.