## Modular Compilers Based on Monad Transformers (1998)

### Cached

### Download Links

- [www-sal.cs.uiuc.edu]
- [www-sal.cs.uiuc.edu]
- DBLP

### Other Repositories/Bibliography

Venue: | In Proceedings of the IEEE International Conference on Computer Languages |

Citations: | 20 - 2 self |

### BibTeX

@INPROCEEDINGS{Harrison98modularcompilers,

author = {William L. Harrison and Samuel N. Kamin},

title = {Modular Compilers Based on Monad Transformers},

booktitle = {In Proceedings of the IEEE International Conference on Computer Languages},

year = {1998},

pages = {122--131},

publisher = {Society Press}

}

### OpenURL

### Abstract

The monadic style of language specification has the advantages of modularity and extensibility: it is simple to add or change features in an interpreter to reflect modifications in the source language. It has proven difficult to extend the method to compilation. We demonstrate that by introducing machine-like stores (code and data) into the monadic semantics and then partially evaluating the resulting semantic expressions, we can achieve many of the same advantages for a compiler as for an interpreter. A number of language constructs and features are compiled: expressions, CBV and CBN evaluation of -expressions, dynamic scoping, and various imperative features. The treatment of recursive procedures is outlined as well. The resulting method allows compilers to be constructed in a mix-and-match fashion just as in a monad-structured interpreter. 1 Introduction and Related Work This paper concerns the construction of modular compilers for high-level programming languages from reusable co...

### Citations

1309 | Monads for Functional Programming
- Wadler
- 1995
(Show Context)
Citation Context ... deleted easily, allowing the compiler writer to develop compilers at a high level of abstraction. Modularity in our compilers comes from the fact that our language semantics is structured with monads=-=[14, 19]-=- and monad transformers[6, 12]. Monads may be viewed as abstract data types whose operations may be used to give denotational definitions of programming languages. Monad transformers create a new mona... |

733 | Notions of Computation and Monads
- Moggi
- 1991
(Show Context)
Citation Context ... deleted easily, allowing the compiler writer to develop compilers at a high level of abstraction. Modularity in our compilers comes from the fact that our language semantics is structured with monads=-=[14, 19]-=- and monad transformers[6, 12]. Monads may be viewed as abstract data types whose operations may be used to give denotational definitions of programming languages. Monad transformers create a new mona... |

473 | Denotational Semantics: the Scott-Strachey Approach to Programming Languages Theory - Stoy - 1977 |

233 | Monad Transformers and Modular Interpreters
- Liang, Hudak, et al.
- 1995
(Show Context)
Citation Context ...ompiler writer to develop compilers at a high level of abstraction. Modularity in our compilers comes from the fact that our language semantics is structured with monads[14, 19] and monad transformers=-=[6, 12]-=-. Monads may be viewed as abstract data types whose operations may be used to give denotational definitions of programming languages. Monad transformers create a new monad by extending an existing mon... |

207 | Type-directed partial evaluation
- Danvy
(Show Context)
Citation Context ... omitted to make the residual code look like machine language. The result of partial evaluation is as shown in Figure 8. This code generation technique is a monadic version of Danvy and Vestergaard's =-=[4, 5]-=-. 3 [a 7! v] : Sto ! Sto is the usual update function which changes the value of a store at a. n 2 Numeral c 2 Cmd ::= c 1 ;c 2 j Addr:=Exp j if Bool then c t 2 Exp ::= n b 2 Bool ::= T rue j F alse j... |

146 |
Component-Based Semantics
- Mosses
- 2009
(Show Context)
Citation Context ...at the meaning of [[\Gamma]] can be reinterpreted in a variety of monads. Monadic semantics separate the description of a language from its denotation. In this sense, it is similar to action semantics=-=[15]-=- and high-level semantics[10]. The simplest monad is the identity monad, shown in Figure 3. Given the identity monad, we can definesadd as ordinary addition. [[\Gamma]] would have type Expression! int... |

131 | Modern Compiler Implementation in ML - Appel - 1998 |

53 |
Realistic Compiler Generation
- Lee
- 1989
(Show Context)
Citation Context ...nstructed by applying the monad transformers associated with each feature in the language. Here, we extend that approach to compilers. To obtain compilers by partial evaluation of semantic definitions=-=[5, 8, 10]-=-, we must introduce data structures for pass separation [9]. This work demonstrates that, by exploiting the monadic structure of our language semantics, pass separation can be done in a modular way. T... |

51 |
Deriving Target Code as a Representation of Continuation Semantics
- Wand
- 1982
(Show Context)
Citation Context ... partially evaluating. Their interpreter had no monadic structure, so that each pass separation must be done by hand. Our work continues a long line of generating compilers from denotational semantics=-=[8, 10, 20]-=-. What primarily distinguishes our work is the use of monads and monad transformers to structure our semantics. Benaissa, et al.[3], transform an interpreter for the while language into a compiler usi... |

36 | Semantic Lego
- Espinosa
- 1995
(Show Context)
Citation Context ...ompiler writer to develop compilers at a high level of abstraction. Modularity in our compilers comes from the fact that our language semantics is structured with monads[14, 19] and monad transformers=-=[6, 12]-=-. Monads may be viewed as abstract data types whose operations may be used to give denotational definitions of programming languages. Monad transformers create a new monad by extending an existing mon... |

36 |
Compilers and staging transformations
- Jørring, Scherlis
- 1986
(Show Context)
Citation Context ...feature in the language. Here, we extend that approach to compilers. To obtain compilers by partial evaluation of semantic definitions[5, 8, 10], we must introduce data structures for pass separation =-=[9]-=-. This work demonstrates that, by exploiting the monadic structure of our language semantics, pass separation can be done in a modular way. Thus, language features can be combined easily, while retain... |

28 | Modular Monadic Semantics and Compilation
- Liang
- 1998
(Show Context)
Citation Context ... 5: return [1,1]; !0,0? := [!0,2?]*[!0,3?]; 6: jump 5; !0,2? := [!0,1?]; 7: halt; !0,3? := 1; Figure 20: Compiling a recursive procedure to establish a formal correctness proof. Claims have been made =-=[6, 11, 13]-=- that proofs about monadic specifications retain some modularity as well, and a correctness proof of our method would be a good test of this. Another goal for future research is the compilation of lan... |

24 | Semantics-based compiling: A case study in typedirected partial evaluation
- Danvy, Vestergaard
- 1996
(Show Context)
Citation Context ...nstructed by applying the monad transformers associated with each feature in the language. Here, we extend that approach to compilers. To obtain compilers by partial evaluation of semantic definitions=-=[5, 8, 10]-=-, we must introduce data structures for pass separation [9]. This work demonstrates that, by exploiting the monadic structure of our language semantics, pass separation can be done in a modular way. T... |

10 |
Using functor categories to generate intermediate code
- Reynolds
- 1995
(Show Context)
Citation Context ...duces a completely dynamic term, composed of a sequence of combinators, looking very much like machine language. This approach is key to making the monadic structure useful for compilation. Reynolds' =-=[17]-=- demonstration of how to produce efficient code in a compiler derived from the functor category semantics of an Algol-like language was an original inspiration for this study. Our compiler for that la... |

7 |
A modular semantics for compiler generation
- Liang
- 1995
(Show Context)
Citation Context ...ormers to create modular, extensible interpreters. This work shows how interpreters can be developed in a modular way, leaving open the question of whether compilers can be developed similarly. Liang =-=[11, 13]-=- addresses that question, proposing that monadic semantics constructed from monad transformers and monadic specifications provide a modular and extensible basis for semantics-directed compilation. He ... |

4 |
The Essence of Algol," Algorithmic Languages
- Reynolds
- 1981
(Show Context)
Citation Context ... of c. Its standard semantics is presented in Figure 18. A location S is allocated and the integer variable i is bound to an acceptor-expresser pair which writes and reads to and from S as in Reynolds=-=[16]-=-. deAlloc is used to deallocate S. The specification for assignment looks up the acceptor-expresser pair associated with i, and passes the appropriate continuation on to the integer expression e. The ... |

1 |
Compilers as staged monadic interpreters," Oregon Graduate Institute
- Benaissa, Sheard, et al.
- 1997
(Show Context)
Citation Context ...ce Code: new g:intvar in let f = v: intvar:se: intexp: v := 1 + e ; v := (g + 1) + e in f g (g + 1) Target Code: 0 := 0; 2 := 1; 1 := 1; 1 := [1] + [2]; 2 := [0]; 2 := [0]; 3 := 1; 3 := 1; 2 := [2] + =-=[3]-=-; 2 := [2] + [3]; 0 := [1] + [2]; 0 := [1] + [2]; 1 := [0]; halt; Figure 2: Algol Example Espinosa [6] and Hudak, Liang, and Jones [12] use monad transformers to create modular, extensible interpreter... |

1 | Deriving Compilers from Monadic Semantics," Unpublished manuscript available at http://wwwsal. cs.uiuc.edu/~harrison/pubs/proposal.ps.Z - Harrison, Kamin |