|
ABSTRACT
We exhibit a set of functions coded in Haskell that can be used as building blocks to construct a variety of interpreters for Lisp-like languages. The building blocks are joined merely through functional composition. Each building block contributes code to support a specific feature, such as numbers, continuations, functions calls, or nondeterminism. The result of composing some number of building blocks is a parser, an interpreter, and a printer that support exactly the expression forms and data types needed for the combined set of features, and no more.
The data structures are organized as pseudomonads, a generalization of monads that allows composition. Functional composition of the building blocks implies type composition of the relevant pseudomonads.
Our intent was that the Haskell type resolution system ought to be able to deduce the appropriate data types automatically. Unfortunately there is a deficiency in current Haskell implementations related to recursive data types: circularity must be reflected statically in the type definitions.
We circumvent this restriction by applying a purpose-built program simplifier that performs partial evaluation and a certain amount of program algebra. We construct a wide variety of interpreters in the style of Wadler by starting with the building blocks and a page of boiler-plate code, writing three lines of code (one to specify the building blocks and two to (redundantly) specify type compositions), and then applying the simplifier. The resulting code is acceptable Haskell code.
We have tested a dozen different interpreters with various combinations of features. In this paper we discuss the overall code structuring strategy, exhibit several building blocks, briefly describe the partial evaluator, and present a number of automatically generated interpreters.
REFERENCES
Note: OCR errors may be found in this Reference List extracted from the full text article. ACM has opted to expose the complete List rather than only correct and linked references.
| |
1
|
Apple Computer, Inc. Inside Maczntosh (five volumes). Addison-Wesley (Reading, Massachusetts, 1985-86).
|
| |
2
|
Hudak, Paul, Peyton Jones, Simon, and Wadler, Philip, editors. Report on the Programming Language Haskell: A Non-Strict, Purely Functional Language (Version 1.1). Technical Report. Yale University and Glasgow University (New Haven Glasgow (r sp~~tiwly), August 1991).
|
| |
3
|
Jones, Mark P. Personal communication to Guy Steele, September 1993.
|
 |
4
|
|
| |
5
|
|
| |
6
|
Moggi, Eugenio. An Abstract Vzew of Programmint Languages. Technical Report ECS-LFCS-90- 113. Laboratory for Foundations of Computer Science, University of Edinburgh (Edinburgh, Scotland, April 1990). Lecture notes for a course taught at Stanford University, Spring 1989.
|
 |
7
|
|
| |
8
|
|
| |
9
|
Rees, Jonathan. Personal communication to Guy Steele, October 1993.
|
 |
10
|
|
| |
11
|
Steele, Guy L., Jr. How to Compose Monads. Technical Report. Thinking Machines Corporation (Cambridge, Massachusetts, July 1993). Unpublished.
|
| |
12
|
|
| |
13
|
|
| |
14
|
|
 |
15
|
|
 |
16
|
|
 |
17
|
|
| |
18
|
|
| |
19
|
Wegbreit, Ben, Holloway, Glenn, Spitzen, Jay, and Townley, Judy. ECL Programmer's Manual. Technical Report 23-74. Harvard University Center for Research in Computing Technology (Cambridge, Massachusetts, December 1974).
|
CITED BY 21
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Sheng Liang , Paul Hudak , Mark Jones, Monad transformers and modular interpreters, Proceedings of the 22nd ACM SIGPLAN-SIGACT symposium on Principles of programming languages, p.333-343, January 23-25, 1995, San Francisco, California, United States
|
|
|
|
|
|
|
|
|
Paul Hudak , John Hughes , Simon Peyton Jones , Philip Wadler, A history of Haskell: being lazy with class, Proceedings of the third ACM SIGPLAN conference on History of programming languages, p.12-1-12-55, June 09-10, 2007, San Diego, California
|
|
|
Gary T. Leavens , Curtis Clifton, Multiple concerns in aspect-oriented language design: a language engineering approach to balancing benefits, with examples, Proceedings of the 5th workshop on Engineering properties of languages and aspect technologies, p.6-es, March 12-16, 2007, Vancouver, British Columbia, Canada
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|