A unifying approach to goal-directed evaluation

  • Authors:
  • Olivier Danvy;Bernd Grobauer;Morten Rhiger

  • Affiliations:
  • BRICS, Department of Computer Science, University of Aarhus, Aarhus C, Denmark;BRICS, Department of Computer Science, University of Aarhus, Aarhus C, Denmark;BRICS, Department of Computer Science, University of Aarhus, Aarhus C, Denmark

  • Venue:
  • SAIG'01 Proceedings of the 2nd international conference on Semantics, applications, and implementation of program generation
  • Year:
  • 2001
  • Defunctionalization at work

    Proceedings of the 3rd ACM SIGPLAN international conference on Principles and practice of declarative programming

Quantified Score

Hi-index 0.00

Visualization

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.