Skip to main content
Log in

Dictionary-free overloading by partial evaluation

  • Published:
LISP and Symbolic Computation

Abstract

One of the most novel features in the functional programming language Haskell is the system oftype classes used to support a combination of overloading and polymorphism. Current implementations of type class overloading are based on the use ofdictionary values, passed as extra parameters to overloaded functions. Unfortunately, this can have a significant effect on run-time performance, for example, by reducing the effectiveness of important program analyses and optimizations.

This paper describes how a simple partial evaluator can be used to avoid the need for dictionary values at run-time by generating specialized versions of overloaded functions. This eliminates the run-time costs of overloading. Furthermore, and somewhat surprisingly given the presence of multiple versions of some functions, for all of the examples that we have tried so far, specialization actually leads to a reduction in the size of compiled programs.

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

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Similar content being viewed by others

References

  1. Lennart Augustsson. Implementing Haskell overloading. InFPCA '93: Conference on Functional Programming Languages and Computer Architecture, Copenhagen, Denmark, pages 65–73. ACM Press, 1993.

  2. C. Chambers and D. Ungar. Customization: Optimizing compiler technology for Self, a dynamically-typed object-oriented programming language. InACM SIGPLAN '91 Conference on Programming Language Design and Implementation, pages 146–160. ACM Press, 1989.

  3. C. Consel and O. Danvy. Tutorial notes on partial evaluation. InTwentieth ACM Symposium on Principles of Programming Languages, Charleston, South Carolina, January 1993, pages 493–501. ACM Press, 1993.

  4. C. Consel and P. Jouvelot. Separate polyvariant binding-time analysis. Technical report CS/E 93-006, Oregon Graduate Institute, Department of Computer Science, March 1993.

  5. C. K. Gomard and N. D. Jones. A partial evaluator for the untyped lambda-calculus.Journal of Functional Programming 1(1): 21–69, 1991.

    Google Scholar 

  6. D. Gries and N. Gehani. Some ideas on data types in high-level languages.Communications of the ACM 20 (6): 414–420, 1977.

    Google Scholar 

  7. F. Henglein and J. Jørgensen. Formally optimal boxing. InPOPL'94: 21st ACM Symposium on Principles of Programming Languages, pages 213–226. ACM Press, 1994.

  8. P. Hudak and J. Fasel. A gentle introduction to Haskell.ACM SIGPLAN Notices 27 (5), May 1992. Also available as Research Report YALEU/DCS/RR-901, Yale University, Department of Computer Science, April 1992.

  9. P. Hudak, S. Peyton Jones, and P. Wadler, editors. Report on the programming language Haskell, a non-strict purely functional language (version 1.2).ACM SIGPLAN Notices 27 (5), May 1992.

  10. Mark P. Jones. Computing with lattices: An application of type classes.Journal of Functional Programming 2 (4): 475–503, 1992.

    Google Scholar 

  11. Mark P. Jones.Qualified Types: Theory and Practice. PhD thesis, Programming Research Group, Oxford University Computing Laboratory, July 1992. Published by Cambridge University Press in the Distinguished Dissertations in Computer Science Series.

  12. Mark P. Jones. Partial evaluation for dictionary-free overloading. Research Report YALEU/DCS/RR-959, Yale University, New Haven, Connecticut, USA, April 1993.

    Google Scholar 

  13. N. D. Jones, P. Sestoft, and H. Søndergaard. An experiment in partial evaluation: The generation of a compiler generator. In J.-P. Jouannaud, editor,Rewriting Techniques and Applications, LNCS 202, pages 124–140. Springer-Verlag, 1985.

  14. S. L. Peyton Jones and J. Launchbury. Unboxed values as first class citizens in a non-strict functional language. In J. Hughes, editor,Fifth ACM Conference on Functional Programming Languages and Computer Architecture, LNCS 523, pages 636–666. Springer-Verlag, 1991.

  15. S. L. Peyton Jones and P. Wadler. A static semantics for Haskell (draft). Technical report, Department of Computing Science, University of Glasgow, February 1992.

  16. S. C. Khoo and R. S. Sundaresh. Compiling inheritance using partial evaluation.Symposium on Partial Evaluation and Semantics-Based Program Manipulation (PEPM'91), pages 211–222. ACM Press, 1991.

  17. X. Leroy. Efficient data representation in polymorphic languages. Research report 1264, INRIA, July 1990.

  18. X. Leroy. Unboxed objects and polymorphic typing. InNineteenth Annual ACM Symposium on Principles of Programming Languages, pages 177–188. ACM Press, 1992.

  19. R. Morrison, A. Dearle, R. C. H. Connor, and A. L. Brown. An ad-hoc approach to the implementation of polymorphism.ACM Transactions on Programming Languages and Systems 13 (3): 342–371, 1991.

    Google Scholar 

  20. F. Nielson. A formal type system for comparing partial evaluators. In D. Bjørner, A. P. Ershov, and N. D. Jones, editors,Partial Evaluation and Mixed Computation, pages 349–384. North-Holland, 1988.

  21. J. Peterson and M. P. Jones. Implementing type classes. InACM SIGPLAN Conference on Programming Language Design and Implementation. SIGPLAN Notices28 (6): 227–236, 1993.

    Google Scholar 

  22. P. Wadler and S. Blott. How to makead hoc polymorphism lessad hoc. InSixteenth ACM Symposium on Principles of Programming Languages, pages 60–76. ACM Press, 1989.

  23. D. Weise and S. Seligman. Accelerating object-oriented simulation via automatic program specialization. Technical Report CSL-TR-92-519, Department of Electrical Engineering and Computer Science, Stanford University, April 1992.

Download references

Author information

Authors and Affiliations

Authors

Additional information

This work was carried out while the author was a member of the Department of Computer Science, Yale University, and was supported in part by a grant from ARPA, contract number N00014-91-J-4043.

Rights and permissions

Reprints and permissions

About this article

Cite this article

Jones, M.P. Dictionary-free overloading by partial evaluation. Lisp and Symbolic Computation 8, 229–248 (1995). https://doi.org/10.1007/BF01019005

Download citation

  • Issue Date:

  • DOI: https://doi.org/10.1007/BF01019005

Keywords

Navigation