Skip to main content

Fold-Unfold Transformations on State Monadic Interpreters

  • Conference paper
Functional Programming, Glasgow 1994

Part of the book series: Workshops in Computing ((WORKSHOPS COMP.))

Abstract

In this paper we advocate the use of fold-unfold transformations for mastering the complexity of abstract machines intended for real implementations. The idea is to express the abstract machine as an interpreter in a purely functional language. The initial interpreter should be ‘obviously correct’ (but might be inefficient — we don’t care at this point). Fold-unfold transformations are then used to remove inefficiencies in the interpreter/abstract machine. We illustrate this by deriving (the equivalent of) the ε-scheme of the G-machine from (the equivalent of) the composition of C and the EVAL instruction. This is first done on a call-by-name (tree reduction) interpreter. To model sharing and the graph manipulation that goes on in a real graph reduction implementation, we use state monads. We do the same transformation of the state monadic interpreter. It is much less straightforward to transform the state monadic interpreter, as we have to lean heavily on the laws of the state monad. In return the state monadic interpreter can be said to better model a real implementation.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 84.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 109.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Similar content being viewed by others

References

  1. G. Argo. Improving the three instruction machine. In Proceedings of the 1989 Conference on Functional Languages and Computer Architecture, pages 100–115, London, England, 1989.

    Google Scholar 

  2. G. M. Argo. Efficient Laziness (under revision). PhD thesis, Glasgow University, 1990.

    Google Scholar 

  3. R. M. Burstall and J. Darlington. A Transformation System for Developing Recursive Programs. Journal of the ACM, 24: 44–67, 1977.

    Article  MathSciNet  MATH  Google Scholar 

  4. FW87] J. Fairbairn and S. C. Wray. TIM: A simple, lazy abstract machine to execute supercombinators. In Proceedings of the 1987 Conference on Functional Programming Languages and Computer Architecture,Portland, Oregon, September 1987.

    Google Scholar 

  5. T. Johnsson. Efficient Compilation of Lazy Evaluation. In Proceedings of the SIGPLAN ‘84 Symposium on Compiler Construction, pages 58–69, Montreal, 1984.

    Google Scholar 

  6. Will Partain. The nofib benchmark suite of haskell programs. In John Launchbury and Patrick Sansom, editors, Proc. 1992 Glasgow Workshop on Functional Programming, pages 195–202. Springer—Verlag, 1993.

    Google Scholar 

  7. S. L. Peyton Jones. The Implementation of Functional Programming Languages. Prentice Hall, 1987.

    Google Scholar 

  8. S. L. Peyton Jones. Implementing lazy functional languages on stock hardware: the Spineless Tagless G-machine. Journal of Functional Programming, 2 (2), April 1992.

    Google Scholar 

  9. S. L. Peyton Jones and Jon Salkild. The Spineless Tagless G-machine. In Proceedings of the 1989 Conference on Functional Programming Languages and Computer Architecture, London, Great Britain, 1989.

    Google Scholar 

  10. S.L Peyton Jones and P. Wadler. Imperative Functional programming. In Proceedings 1993 Symposium Principles of Programming Languages, Charleston, N.Carolina, 1993.

    Google Scholar 

  11. P. Wadler. Comprehending Monads. In Proceedings of the 1990 ACM Symposium on Lisp and Functional Programming, Nice, France, 1990.

    Google Scholar 

  12. P. Wadler. The essence of functional programming. In Proceedings 1992 Symposium on principles of Programming Languages, pages 114, Albuquerque, New Mexico, 1992.

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 1995 Springer-Verlag London

About this paper

Cite this paper

Johnsson, T. (1995). Fold-Unfold Transformations on State Monadic Interpreters. In: Hammond, K., Turner, D.N., Sansom, P.M. (eds) Functional Programming, Glasgow 1994. Workshops in Computing. Springer, London. https://doi.org/10.1007/978-1-4471-3573-9_9

Download citation

  • DOI: https://doi.org/10.1007/978-1-4471-3573-9_9

  • Publisher Name: Springer, London

  • Print ISBN: 978-3-540-19914-4

  • Online ISBN: 978-1-4471-3573-9

  • eBook Packages: Springer Book Archive

Publish with us

Policies and ethics