Unboxed values as first class citizens in a non-strict functional language

  • Simon L Peyton Jones
  • John Launchbury
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 523)


The code compiled from a non-strict functional program usually manipulates heap-allocated boxed numbers. Compilers for such languages often go to considerable trouble to optimise operations on boxed numbers into simpler operations on their unboxed forms. These optimisations are usually handled in an ad hoc manner in the code generator, because earlier phases of the compiler have no way to talk about unboxed values.

We present a new approach, which makes unboxed values into (nearly) first-class citizens. The language, including its type system, is extended to handle unboxed values. The optimisation of boxing and unboxing operations can now be reinterpreted as a set of correctness-preserving program transformations. Indeed the particular transformations required are ones which a compiler would want to implement anyway. The compiler becomes both simpler and more modular.

Two other benefits accrue. Firstly, the results of strictness analysis can be exploited within the same uniform transformational framework. Secondly, new algebraic data types with unboxed components can be declared. Values of these types can be manipulated much more efficiently than the corresponding boxed versions.

Both a static and a dynamic semantics are given for the augmented language. The denotational dynamic semantics is notable for its use of unpointed domains.


Program Transformation Denotational Semantic Type Constructor Dynamic Semantic Recursive Definition 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. AW Appel [1988], “Runtime tags aren't necessary,” CS-TR-142-88, Department of Computer Science, Princeton University.Google Scholar
  2. AW Appel & T Jim [Jan 1989], “Continuation-passing, closure-passing, style,” in Proc ACM Conference on Principles of Programming Languages, ACM, 293–302.Google Scholar
  3. TH Brus, MCJD van Eckelen, MO van Leer & MJ Plasmeijer [Sept 1987], “Clean — a language for functional graph rewriting,” in Functional programming languages and computer architecture, Portland, G Kahn, ed., LNCS 274, Springer Verlag, 364–384.Google Scholar
  4. LMM Damas & R Milner [1982], “Principal type schemes for functional programs,” in POPL, 207–212.Google Scholar
  5. P Fradet & D Le Metayer [1990], “Compilation of functional languages by program transformation,” IRISA, Campus de Beaulieu, Rennes.Google Scholar
  6. P Fradet & D Le Metayer [June 1988], “Compilation of lambda-calculus into functional machine code,” INRIA.Google Scholar
  7. [1986], in Abstract Interpretation of Declarative Languages, C Hankin & S Abramsky, eds., Ellis Horwood, Chichester, 246–265.Google Scholar
  8. P Hudak, PL Wadler, Arvind, B Boutel, J Fairbairn, J Fasel, K Hammond, J Hughes, T Johnsson, R Kieburtz, RS Nikhil, SL Peyton Jones, M Reeve, D Wise & J Young [April 1990], “Report on the functional programming language Haskell,” Department of Computing Science, Glasgow University.Google Scholar
  9. R Kelsey [May 1989], “Compilation by program transformation,” YALEU/DCS/RR-702, PhD thesis, Department of Computer Science, Yale University.Google Scholar
  10. DA Kranz [May 1988], “ORBIT — an optimising compiler for Scheme,” PhD thesis, Department of Computer Science, Yale University.Google Scholar
  11. X Leroy [April 1991], “Efficient data representations in polymorphic languages,” INRIA Research Report 1264, Rocquencourt.Google Scholar
  12. E Moggi [June 1989], “Computational lambda calculus and monads,” in Logic in Computer Science, California, IEEE.Google Scholar
  13. J Peterson [Sept 1989], “Untagged data in tagged environments: choosing optimal representations at compile time,” in Functional Programming Languages and Computer Architecture, London, Addison Wesley, 89–99.Google Scholar
  14. SL Peyton Jones [1987], The implementation of functional programming languages, Prentice Hall.Google Scholar
  15. SL Peyton Jones [Feb 1991], “The Spineless Tagless G-machine: a second attempt,” Department of Computing Science, University of Glasgow.Google Scholar
  16. SL Peyton Jones & Jon Salkild [Sept 1989], “The Spineless Tagless G-machine,” in Functional Programming Languages and Computer Architecture, D Mac-Queen, ed., Addison Wesley.Google Scholar
  17. DA Schmidt [1986], Denotational semantics: a methodology for language development, Allyn and Bacon.Google Scholar
  18. MB Smyth & GD Plotkin [Nov 1982], “The category-theoretic solution of recursive domain equations,” SIAM Journal of Computing 11, 761–783.Google Scholar
  19. GL Steele [1978], “Rabbit: a compiler for Scheme,” AI-TR-474, MIT Lab for Computer Science.Google Scholar
  20. SR Thatte [1990], “Coercive type equivalence,” Department of Maths and Computer Science, Clarkson University NY.Google Scholar
  21. P Wadler [1990], “Deforestation: transforming programs to eliminate trees,” Theoretical Computer Science 73, 231–248.Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 1991

Authors and Affiliations

  • Simon L Peyton Jones
    • 1
  • John Launchbury
    • 1
  1. 1.Department of Computing ScienceUniversity of GlasgowUK

Personalised recommendations