skip to main content
10.1145/581690.581698acmconferencesArticle/Chapter ViewAbstractPublication PagesicfpConference Proceedingsconference-collections
Article

A lightweight implementation of generics and dynamics

Authors Info & Claims
Published:03 October 2002Publication History

ABSTRACT

The recent years have seen a number of proposals for extending statically typed languages by dynamics or generics. Most proposals --- if not all --- require significant extensions to the underlying language. In this paper we show that this need not be the case. We propose a particularly lightweight extension that supports both dynamics and generics. Furthermore, the two features are smoothly integrated: dynamic values, for instance, can be passed to generic functions. Our proposal makes do with a standard Hindley-Milner type system augmented by existential types. Building upon these ideas we have implemented a small library that is readily usable both with Hugs and with the Glasgow Haskell compiler.

References

  1. Martín Abadi, Luca Cardelli, Benjamin Pierce, and Didier Rémy. Dynamic typing in polymorphic languages. Journal of Functional Programming, 5(1):111-130, January 1995.]]Google ScholarGoogle ScholarCross RefCross Ref
  2. Martín Abadi, Luca Cardelli, Benjamin Pierce, and Gordon Plotkin. Dynamic typing in a statically typed language. ACM Transactions on Programming Languages and Systems, 13(2):237-268, April 1991.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Artem Alimarine and Rinus Plasmeijer. A generic programming extension for Clean. In Th. Arts and M. Mohnen, editors, Proceedings of the 13th International workshop on the Implementation of Functional Languages, IFL '01, pages 257-278, Älvsjö, Sweden, September 2001.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Arthur I. Baars and S. Doaitse Swierstra. Typing dynamic typing. In Simon Peyton Jones, editor, Proceedings of the 2002 International Conference on Functional Programming, Pittsburgh, PA, USA, October 4-6, 2002. ACM Press, October 2002. To appear.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Roland Backhouse, Patrik Jansson, Johan Jeuring, and Lambert Meertens. Generic Programming --- An Introduction. In S. Doaitse Swierstra, Pedro R. Henriques, and Jose N. Oliveira, editors, 3rd International Summer School on Advanced Functional Programming, Braga, Portugal, volume 1608 of Lecture Notes in Computer Science, pages 28-115. Springer-Verlag, Berlin, 1999.]]Google ScholarGoogle Scholar
  6. Richard Bird and Lambert Meertens. Nested datatypes. In J. Jeuring, editor, Fourth International Conference on Mathematics of Program Construction, MPC '98, Marstrand, Sweden, volume 1422 of Lecture Notes in Computer Science, pages 52-67. Springer-Verlag, June 1998.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Dæv Clarke, Ralf Hinze, Johan Jeuring, Andres Löh, and Jan de Wit. The Generic Haskell user's guide. Technical Report UU-CS-2001-26, Universiteit Utrecht, November 2001.]]Google ScholarGoogle Scholar
  8. Karl Crary and Stephanie Weirich. Flexible type analysis. In Proceedings of the ACM SIGPLAN International Conference on Functional Programming (ICFP '99), Paris, France, volume (34)9 of ACM SIGPLAN Notices, pages 233-248. ACM Press, September 1999.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Karl Crary, Stephanie Weirich, and Greg Morrisett. Intensional polymorphism in type-erasure semantics. In Proceedings of the ACM SIGPLAN International Conference on Functional Programming (ICFP '98), Baltimore, MD, volume (34)1 of ACM SIGPLAN Notices, pages 301-312. ACM Press, January 1999.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Rowan Davies and Frank Pfenning. A modal analysis of staged computation. Journal of the ACM, 48(3):555-604, May 2001.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Cordelia V. Hall, Kevin Hammond, Simon L. Peyton Jones, and Philip L. Wadler. Type classes in Haskell. ACM Transactions on Programming Languages and Systems, 18(2):109-138, March 1996.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Michael Hanus. Horn clause programs with polymorphic types: semantics and resolution. Theoretical Computer Science, 89(1):63-106, October 1991.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Robert Harper and Mark Lillibridge. A type-theoretic approach to higher-order modules with sharing. In Conference Record of the 21st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL '94), Portland, Oregon, pages 123-137, New York, NY, January 1994. ACM.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Robert Harper and Greg Morrisett. Compiling polymorphism using intensional type analysis. In Conference record of the 22nd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL '95), San Francisco, California, pages 130-141. ACM Press, 1995.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Ralf Hinze. Memo functions, polytypically! In Johan Jeuring, editor, Proceedings of the 2nd Workshop on Generic Programming, Ponte de Lima, Portugal, pages 17-32, July 2000. The proceedings appeared as a technical report of Universiteit Utrecht, UU-CS-2000-19.]]Google ScholarGoogle Scholar
  16. Ralf Hinze. A new approach to generic functional programming. In Thomas W. Reps, editor, Proceedings of the 27th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL '00), Boston, Massachusetts, January 19-21, pages 119-132, January 2000.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Ralf Hinze. Polytypic values possess polykinded types. Science of Computer Programming, 2002. To appear.]]Google ScholarGoogle ScholarCross RefCross Ref
  18. Ralf Hinze and Simon Peyton Jones. Derivable type classes. In Graham Hutton, editor, Proceedings of the 2000 ACM SIGPLAN Haskell Workshop, volume 41.1 of Electronic Notes in Theoretical Computer Science. Elsevier Science, August 2001. The preliminary proceedings appeared as a University of Nottingham technical report.]]Google ScholarGoogle Scholar
  19. Patrik Jansson and Johan Jeuring. PolyP---a polytypic programming language extension. In Conference Record of the 24th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL '97), Paris, France, pages 470-482. ACM Press, January 1997.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Xavier Leroy. Manifest types, modules, and separate compilation. In Conference Record of the 21st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL '94), Portland, Oregon, pages 109-122, New York, NY, January 1994. ACM.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Xavier Leroy and Michel Mauny. Dynamics in ML. Journal of Functional Programming, 3(4):431-463, 1993.]]Google ScholarGoogle ScholarCross RefCross Ref
  22. Yasuhiko Minamide, Greg Morrisett, and Robert Harper. Typed closure conversion. In Conference Record of the 23rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL '96), pages 271-283, St. Petersburg Beach, Florida, January 1996.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Simon Peyton Jones and John Hughes, editors. Haskell 98 --- A Non-strict, Purely Functional Language, February 1999. Available from http://www.haskell.org/definition/.]]Google ScholarGoogle Scholar
  24. Simon Peyton Jones, Andrew Tolmach, and Tony Hoare. Playing by the rules: Rewriting as an optimization technique in GHC. In Ralf Hinze, editor, Proceedings of the 2001 ACM SIGPLAN Haskell Workshop (HW '2001), 2nd September 2001, Firenze, Italy, Electronic Notes in Theoretical Computer Science, Vol. 59, pages 203-233, September 2001. The preliminary proceedings appeared as a Universiteit Utrecht technical report, UU-CS-2001-62.]]Google ScholarGoogle Scholar
  25. Benjamin C. Pierce. Types and programming languages. MIT Press, Cambridge, Mass., 2002.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Marco Pil. Dynamic types and type dependent functions. In Kevin Hammond, Antony J. T. Davie, and Chris Clack, editors, Implementation of Functional Languages, 10th International Workshop, IFL '98, London, UK, September 9-11, Selected Papers, volume 1595 of Lecture Notes in Computer Science, pages 169-185. Springer, 1999.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Mark Shields, Tim Sheard, and Simon Peyton Jones. Dynamic typing as staged type inference. In The 25th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL '98), pages 289-302, New York, January 1998. ACM.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Walid Taha and Tim Sheard. Multi-stage programming with explicit annotations. In Proceedings of the ACM SIGPLAN Symposium on Partial Evaluation and Semantics-Based Program Manipulation (PEPM '97), volume (32)12 of ACM SIGPLAN Notices, pages 203-217, New York, June 1997. ACM Press.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Philip Wadler. Theorems for free! In The Fourth International Conference on Functional Programming Languages and Computer Architecture (FPCA '89), London, UK, pages 347-359. Addison-Wesley Publishing Company, September 1989.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Philip Wadler. The Girard-Reynolds isomorphism. In N. Kobayashi and B. C. Pierce, editors, Proc. of 4th Int. Symp. on Theoretical Aspects of Computer Science, TACS 2001, Sendai, Japan, 29-31 Oct. 2001, volume 2215 of Lecture Notes in Computer Science, pages 468-491. Springer-Verlag, Berlin, 2001.]] Google ScholarGoogle Scholar
  31. Philip Wadler and Stephen Blott. How to make ad-hoc polymorphism less ad hoc. In Proceedings of the 16th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL '89), pages 60-76, Austin, TX, USA, January 1989. ACM Press.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. Stephanie Weirich. Type-safe cast: functional pearl. In Proceedings of the ACM SIGPLAN International Conference on Functional Programming (ICFP '00), volume (35)9 of ACM SIGPLAN Notices, pages 58-67, N.Y., September 2000. ACM Press.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. Stephanie Weirich. Encoding intensional type analysis. In David Sands, editor, Proceedings of the 10th European Symposium on Programming, ESOP 2001, volume 2028 of Lecture Notes in Computer Science, pages 92-106, 2001.]] Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. A lightweight implementation of generics and dynamics

    Recommendations

    Comments

    Login options

    Check if you have access through your login credentials or your institution to get full access on this article.

    Sign in
    • Published in

      cover image ACM Conferences
      Haskell '02: Proceedings of the 2002 ACM SIGPLAN workshop on Haskell
      October 2002
      118 pages
      ISBN:1581136056
      DOI:10.1145/581690

      Copyright © 2002 ACM

      Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 3 October 2002

      Permissions

      Request permissions about this article.

      Request Permissions

      Check for updates

      Qualifiers

      • Article

      Acceptance Rates

      Haskell '02 Paper Acceptance Rate9of24submissions,38%Overall Acceptance Rate57of143submissions,40%

      Upcoming Conference

      ICFP '24

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader