Transforming lazy functions using comportment properties
This paper develops a source-to-source transformation that seeks to delay the creation of thunks as much as possible, often eliminating them altogether. The generated programs make use of simpler representations, including types in which all expressions terminate. The transformation is guided by an abstract interpretation, with the abstract values of basic comportment analysis concretized as representation types related by injections.
The transformation of functions is polyvariant, with functions mapped to natural transformations. This leads to a clean treatment of higher order functions.
Keywordsstatic analysis abstract interpretation automatic program transformation
Unable to display preview. Download preview PDF.
- 1.Geoffrey L. Burn and Daniel Le Métayer. Proving the correctness of compiler optimisations based on a global program analysis. In Fifth International Symposium on Programming Language Implementation and Logic Programming, volume 714 of Lecture Notes in Computer Science, pages 346–364, Tallinn, Estonia, August 1993. Springer.Google Scholar
- 2.Patrick Cousot and Radhia Cousot. Higher-order abstract interpretation (and application to comportment analysis generalizing strictness, termination, projection and PER analysis of functional languages). In International Conference on Computer Languages, pages 95–112. IEEE Computer Society Press, 1994.Google Scholar
- 3.Olivier Danvy and John Hatcliff. CPS-transformation after strictness analysis. ACM Letters on Programming Languages and Systems, 1(3):195–212, 1992.Google Scholar
- 4.G.W. Hamilton. Higher order deforestation. In Programming Languages: Implementations, Logics and Programs, volume 1140 of Lecture Notes in Computer Science, pages 213–227. Springer, 1996.Google Scholar
- 5.A. Reza Haydarlou and Pieter H. Hartel. Thunk lifting: Reducing heap usage in an implementation of a lazy functional language. Journal of Functional and Logic Programming, 1995.Google Scholar
- 6.Brian T. Howard. Inductive, projective, and pointed types. In ACM International Conference on Functional Programming, pages 102–109, Philadelphia, May 1996.Google Scholar
- 7.Sebastian Hunt and David Sands. Binding time analysis: A new PERspective. In ACM Symposium on Partial Evaluation and Semantics-based Program Manipulation, pages 154–165. ACM SIGPLAN Notices 26(9), September 1991.Google Scholar
- 8.John Launchbury and Ross Paterson. Parametricity and unboxing with unpointed types. In European Symposium on Programming, volume 1058 of Lecture Notes in Computer Science, pages 204–218, Linköping, Sweden, April 1996, SpringerGoogle Scholar
- 9.Alan Mycroft. The theory and practice of transforming call-by-need into call-by-value. In B. Robinet, editor, International Symposium on Programming, volume 83 of Lecture Notes in Computer Science, pages 270–281. Springer, 1980.Google Scholar
- 10.Alan Mycroft and Kirsten Lackner Solberg. Uniform pers and comportment analysis. In Programming Languages: Implementations, Logics and Programs, volume 982 of Lecture Notes in Computer Science, pages 169–187. Springer, 1995.Google Scholar
- 11.Ross Paterson. Compiling laziness using projections. In Static Analysis Symposium, volume 1145 of Lecture Notes in Computer Science, pages 255–269, Aachen, Germany, September 1996. Springer.Google Scholar
- 12.Simon L. Peyton Jones and John Launchbury. Unboxed values as first class citizens in a non-strict functional language. In Conference on Functional Programming Languages and Computer Architecture, pages 636–666, Cambridge, MA, 1991.Google Scholar
- 13.Philip Wadler. Deforestation: Transforming programs to eliminate trees. Theoretical Computer Science, 73:231–248, 1990.Google Scholar
- 14.Philip Wadler and John Hughes. Projections for strictness analysis. In Conference on Functional Programming Languages and Computer Architecture, volume 274 of Lecture Notes in Computer Science, pages 385–407, Portland, OR, 1987. Springer.Google Scholar