skip to main content
article

Levity polymorphism

Published:14 June 2017Publication History
Skip Abstract Section

Abstract

Parametric polymorphism is one of the linchpins of modern typed programming, but it comes with a real performance penalty. We describe this penalty; offer a principled way to reason about it (kinds as calling conventions); and propose levity polymorphism. This new form of polymorphism allows abstractions over calling conventions; we detail and verify restrictions that are necessary in order to compile levity-polymorphic functions. Levity polymorphism has created new opportunities in Haskell, including the ability to generalize nearly half of the type classes in GHC's standard library.

References

  1. K. Crary. Toward a foundational typed assembly language. In Proceedings of the 30th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL ’03, pages 198–212. ACM, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. K. Crary and S. Weirich. Flexible type analysis. In Proceedings of the Fourth ACM SIGPLAN International Conference on Functional Programming, ICFP ’99, pages 233–248. ACM, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. J. Dunfield. Elaborating evaluation-order polymorphism. In Proceedings of the 20th ACM SIGPLAN International Conference on Functional Programming, ICFP 2015, pages 256–268. ACM, 2015. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. R. A. Eisenberg. Dependent Types in Haskell: Theory and Practice. PhD thesis, University of Pennsylvania, 2016.Google ScholarGoogle Scholar
  5. R. A. Eisenberg and S. Peyton Jones. Levity polymorphism (extended version). Technical report, Bryn Mawr College, 2017.Google ScholarGoogle Scholar
  6. S. Finne, D. Leijen, E. Meijer, and S. Peyton Jones. Calling Hell from Heaven and Heaven from Hell. In ACM SIGPLAN International Conference on Functional Programming (ICFP’99), pages 114–125, Paris, Sept. 1999. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. C. Flanagan, A. Sabry, B. F. Duba, and M. Felleisen. The essence of compiling with continuations. In Proceedings of the ACM SIGPLAN 1993 Conference on Programming Language Design and Implementation, PLDI ’93, pages 237–247. ACM, 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. J.-Y. Girard. Une extension de l’interpretation de Gödel à l’analyse, et son application à l’élimination des coupures dans l’analyse et la theorie des types. In J. Fenstad, editor, Proceedings of the Second Scandinavian Logic Symposium, volume 63 of Studies in Logic and the Foundations of Mathematics, pages 63 – 92. Elsevier, 1971.Google ScholarGoogle Scholar
  9. D. Grossman. Quantified types in an imperative language. ACM Trans. Program. Lang. Syst., 28(3):429–475, May 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. C. V. Hall, K. Hammond, S. L. Peyton Jones, and P. L. Wadler. Type classes in haskell. ACM Trans. Program. Lang. Syst., 18 (2), Mar. 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. T. Jim, G. Morrisett, D. Grossman, M. Hicks, J. Cheney, and Y. Wang. Cyclone: A safe dialect of C. In Proceedings of the USENIX Annual Technical Conference, pages 275–288, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. A. Kennedy and D. Syme. Design and implementation of generics for the .NET Common Language Runtime. In Programming Language Design and Implementation. ACM, January 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. R. Lämmel and S. Peyton Jones. Scrap your boilerplate: A practical design pattern for generic programming. In Workshop on Types in Languages Design and Implementation. ACM, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. G. Mainland, S. Marlow, R. Leshchinskiy, and S. Peyton Jones. Exploiting vector instructions with generalized stream fusion. In ACM SIGPLAN International Conference on Functional Programming (ICFP ’13). ACM, September 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. S. Marlow (editor). Haskell 2010 language report, 2010.Google ScholarGoogle Scholar
  16. G. Morrisett, D. Walker, K. Crary, and N. Glew. From System F to typed assembly language. ACM Trans. Program. Lang. Syst., 21(3):527–568, May 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. A. Mycroft. Polymorphic type schemes and recursive definitions. Springer, Berlin, Heidelberg, 1984.Google ScholarGoogle ScholarCross RefCross Ref
  18. M. Naftalin and P. Wadler. Java Generics and Collections: Speed Up the Java Development Process. O’Reilly Media, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. M. Odersky and K. Läufer. Putting type annotations to work. In Symposium on Principles of Programming Languages, POPL ’96. ACM, 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. S. Peyton Jones and J. Launchbury. Unboxed values as first class citizens. In FPCA, volume 523 of LNCS, pages 636–666, 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. S. Peyton Jones and A. Santos. A transformation-based optimiser for Haskell. In Science of Computer Programming, volume 32, pages 3–47. Elsevier, October 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. S. Peyton Jones, D. Vytiniotis, S. Weirich, and M. Shields. Practical type inference for arbitrary-rank types. Journal of Functional Programming, 17(1), Jan. 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. S. Peyton Jones, S. Weirich, R. A. Eisenberg, and D. Vytiniotis. A reflection on types. In A list of successes that can change the world, LNCS. Springer, 2016. A festschrift in honor of Phil Wadler.Google ScholarGoogle ScholarCross RefCross Ref
  24. J. C. Reynolds. Towards a theory of type structure. In B. Robinet, editor, Programming Symposium, volume 19 of Lecture Notes in Computer Science, pages 408–425. Springer Berlin Heidelberg, 1974. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. M. Sulzmann, M. M. T. Chakravarty, S. Peyton Jones, and K. Donnelly. System F with type equality coercions. In Types in languages design and implementation, TLDI ’07. ACM, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. D. Tarditi, G. Morrisett, P. Cheng, C. Stone, R. Harper, and P. Lee. TIL: A type-directed optimizing compiler for ML. In Proceedings of the ACM SIGPLAN ’96 Conference on Programming Language Design and Implementation, PLDI ’96, 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. V. Ureche, A. Biboudis, Y. Smaragdakis, and M. Odersky. Automating ad hoc data representation transformations. In International Conference on Object Oriented Programming Systems Languages & Applications, OOPSLA ’15. ACM, 2015. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. P. Wadler and S. Blott. How to make ad-hoc polymorphism less ad-hoc. In POPL, pages 60–76. ACM, 1989. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. S. Weeks. Whole-program compilation in MLton. Invited talk at ML Workshop, Sept. 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. S. Weirich, J. Hsu, and R. A. Eisenberg. System FC with explicit kind equality. In International Conference on Functional Programming, ICFP ’13. ACM, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. B. A. Yorgey, S. Weirich, J. Cretin, S. Peyton Jones, D. Vytiniotis, and J. P. Magalhães. Giving Haskell a promotion. In Types in Language Design and Implementation, TLDI ’12. ACM, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Levity polymorphism

        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

        Full Access

        • Published in

          cover image ACM SIGPLAN Notices
          ACM SIGPLAN Notices  Volume 52, Issue 6
          PLDI '17
          June 2017
          708 pages
          ISSN:0362-1340
          EISSN:1558-1160
          DOI:10.1145/3140587
          Issue’s Table of Contents
          • cover image ACM Conferences
            PLDI 2017: Proceedings of the 38th ACM SIGPLAN Conference on Programming Language Design and Implementation
            June 2017
            708 pages
            ISBN:9781450349888
            DOI:10.1145/3062341

          Copyright © 2017 ACM

          Publisher

          Association for Computing Machinery

          New York, NY, United States

          Publication History

          • Published: 14 June 2017

          Check for updates

          Qualifiers

          • article

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader
        About Cookies On This Site

        We use cookies to ensure that we give you the best experience on our website.

        Learn more

        Got it!