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.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
Similar content being viewed by others
References
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.
G. M. Argo. Efficient Laziness (under revision). PhD thesis, Glasgow University, 1990.
R. M. Burstall and J. Darlington. A Transformation System for Developing Recursive Programs. Journal of the ACM, 24: 44–67, 1977.
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.
T. Johnsson. Efficient Compilation of Lazy Evaluation. In Proceedings of the SIGPLAN ‘84 Symposium on Compiler Construction, pages 58–69, Montreal, 1984.
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.
S. L. Peyton Jones. The Implementation of Functional Programming Languages. Prentice Hall, 1987.
S. L. Peyton Jones. Implementing lazy functional languages on stock hardware: the Spineless Tagless G-machine. Journal of Functional Programming, 2 (2), April 1992.
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.
S.L Peyton Jones and P. Wadler. Imperative Functional programming. In Proceedings 1993 Symposium Principles of Programming Languages, Charleston, N.Carolina, 1993.
P. Wadler. Comprehending Monads. In Proceedings of the 1990 ACM Symposium on Lisp and Functional Programming, Nice, France, 1990.
P. Wadler. The essence of functional programming. In Proceedings 1992 Symposium on principles of Programming Languages, pages 114, Albuquerque, New Mexico, 1992.
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights 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