Abstract
Goal-directed evaluation, as embodied in Icon and Snobol, is built on the notions of backtracking and of generating successive results, and therefore it has always been something of a challenge to specify and implement. In this article, we address this challenge using computational monads and partial evaluation.
We consider a subset of Icon and we specify it with a monadic semantics and a list monad. We then consider a spectrum of monads that also fit the bill, and we relate them to each other. For example, we derive a continuation monad as a Church encoding of the list monad. The resulting semantics coincides with Gudeman’s continuation semantics of Icon. We then compile Icon programs by specializing their interpreter (i.e., by using the first Futamura projection), using type-directed partial evaluation. Through various back ends, including a run-time code generator, we generate ML code, C code, and OCaml byte code. Binding-time analysis and partial evaluation of the continuation-based interpreter automatically give rise to C programs that coincide with the result of Proebsting’s optimized compiler.
Basic Research in Computer Science (www.brics.dk), funded by the Danish National Research Foundation.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
Andrew W. Appel. Compiling with Continuations. Cambridge University Press, New York, 1992.
Lawrence Byrd. Understanding the control of Prolog programs. Technical Report 151, University of Edinburgh, 1980.
Mats Carlsson. On implementing Prolog in functional programming. New Generation Computing, 2(4):347–359, 1984.
Alonzo Church. The Calculi of Lambda-Conversion. Princeton University Press, 1941.
Charles Consel and Olivier Danvy. Tutorial notes on partial evaluation. In Susan L. Graham, editor, Proceedings of the Twentieth Annual ACM Symposium on Principles of Programming Languages, pages 493–501, Charleston, South Carolina, January 1993. ACM Press.
Charles Consel and FranÇois Noёl. A general approach for run-time specialization and its application to C. In Guy L. Steele, editor, Proceedings of the Twenty-Third Annual ACM Symposium on Principles of Programming Languages, pages 145–156, St. Petersburg Beach, Florida, January 1996. ACM Press.
Ron K. Cytron, editor. Proceedings of the ACM SIGPLAN'97 Conference on Programming Languages Design and Implementation, SIGPLAN Notices, Vol. 32, No 5, Las Vegas, Nevada, June 1997. ACM Press.
Olivier Danvy. Type-directed partial evaluation. In John Hatcliff, Torben Æ. Mogensen, and Peter Thiemann, editors, Partial Evaluation-Practice and Theory; Proceedings of the 1998 DIKU Summer School, number 1706 in Lecture Notes in Computer Science, pages 367–411, Copenhagen, Denmark, July 1998. Springer-Verlag.
Olivier Danvy and René Vestergaard. Semantics-based compiling: A case study in type-directed partial evaluation. In Herbert Kuchen and Doaitse Swierstra, editors, Eighth International Symposium on Programming Language Implementation and Logic Programming, number 1140 in Lecture Notes in Computer Science, pages 182–197, Aachen, Germany, September 1996. Springer-Verlag. Extended version available as the technical report BRICS-RS-96-13.
Andrzej Filinski. Representing layered monads. In Alex Aiken, editor, Proceedings of the Twenty-Sixth Annual ACM Symposium on Principles of Programming Languages, pages 175–188, San Antonio, Texas, January 1999. ACM Press.
Ralph E. Griswold and Madge T. Griswold. The Icon Programming Language. Prentice Hall, Inc., 1983.
Ralph E. Griswold and Madge T. Griswold. The Implementation of the Icon Programming Language. Princeton University Press, 1986.
David A. Gudeman. Denotational semantics of a goal-directed language. ACM Transactions on Programming Languages and Systems, 1992.
Robert Hieb, R. Kent Dybvig, and Carl Bruggeman. Representing control in the presence of first-class continuations. In Bernard Lang, editor, Proceedings of the ACM SIGPLAN‘90 Conference on Programming Languages Design and Implementation, SIGPLAN Notices, Vol. 25, No 6, pages 66–77, White Plains, New York, June 1990. ACM Press.
Ralf Hinze. Prological features in a functional setting-axioms and implementations. In Masahiko Sato and Yoshihito Toyama, editors, Third Fuji International Symposium on Functional and Logic Programming (FLOPS‘98), pages 98–122, Kyoto, Japan, April 1998. World Scientific.
John Hughes. A novel representation of lists and its application to the function “reverse”. Information Processing Letters, 22(3):141–144, 1986.
Neil D. Jones, Carsten K. Gomard, and Peter Sestoft. Partial Evaluation and Automatic Program Generation. Prentice-Hall International, 1993. Available online at http://www.dina.kvl.dk/~sestoft/pebook/pebook.html.
David J. King and Philip Wadler. Combining Monads. In John Launchbury and Patrick M. Sansom, editors, Glasgow Workshop on Functional Programming, Workshops in Computing, Ayr, Scotland, 1992. Springer, Berlin.
Mark Leone and Peter Lee. Optimizing ML with run-time code generation. In Proceedings of the ACM SIGPLAN‘96 Conference on Programming Languages Design and Implementation, SIGPLAN Notices, Vol. 31, No 5, pages 137–148. ACM Press, May 1996.
Karoline Malmkjær. Abstract Interpretation of Partial-Evaluation Algorithms. PhD thesis, Department of Computing and Information Sciences, Kansas State University, Manhattan, Kansas, March 1993.
Eugenio Moggi. Computational lambda-calculus and monads. In Proceedings of the Fourth Annual IEEE Symposium on Logic in Computer Science, pages 14–23, Pacific Grove, California, June 1989. IEEE Computer Society Press.
Todd A. Proebsting. Simple translation of goal-directed evaluation. In Cytron [7], pages 1–6.
Todd A. Proebsting and Gregg M. Townsend. A new implementation of the Icon language. Technical Report 99-13, University of Arizona, Department of Computer Science, 1999.
John C. Reynolds. Definitional interpreters for higher-order programming languages. Higher-Order and Symbolic Computation, 11(4):363–397, 1998. Reprinted from the proceedings of the 25th ACM National Conference (1972).
Morten Rhiger. PhD thesis, BRICS PhD School, University of Aarhus, Aarhus, Denmark, 2001. Forthcoming.
Michael Sperber and Peter Thiemann. Two for the price of one: composing partial evaluation and compilation. In Cytron [7], pages 215–225.
Guy L. Steele Jr. Compiler optimization based on viewing LAMBDA as RENAME + GOTO. In Patrick Henry Winston and Richard Henry Brown, editors, Artificial Intelligence: An MIT Perspective, volume 2. The MIT Press, 1979.
Philip Wadler. Comprehending monads. Mathematical Structures in Computer Science, 2(4):461–493, December 1992.
Philip Wadler. Monads for functional programming. In Johan Jeuring and Erik Meijer, editors, Advanced Functional Programming, number 925in Lecture Notes in Computer Science, pages 24–52. Springer-Verlag, 1995.
Richard S. Wallace. An easy implementation of pil (PROLOG in LISP). Association for Computing Machinery Special Interest Group on Artificial Intelligence. SIGART NEWSL., (85):29–32, July 1983.
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2001 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Danvy, O., Grobauer, B., Rhiger, M. (2001). A Unifying Approach to Goal-Directed Evaluation. In: Taha, W. (eds) Semantics, Applications, and Implementation of Program Generation. SAIG 2001. Lecture Notes in Computer Science, vol 2196. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-44806-3_7
Download citation
DOI: https://doi.org/10.1007/3-540-44806-3_7
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-42558-8
Online ISBN: 978-3-540-44806-8
eBook Packages: Springer Book Archive