10.1145/2628136.2628141acmconferencesArticle/Chapter ViewAbstractPublication PagesicfpConference Proceedingsconference-collections
research-article

Safe zero-cost coercions for Haskell

Online:19 August 2014Publication History

ABSTRACT

Generative type abstractions -- present in Haskell, OCaml, and other languages -- are useful concepts to help prevent programmer errors. They serve to create new types that are distinct at compile time but share a run-time representation with some base type. We present a new mechanism that allows for zero-cost conversions between generative type abstractions and their representations, even when such types are deeply nested. We prove type safety in the presence of these conversions and have implemented our work in GHC.

References

  1. Joachim Breitner, Richard A. Eisenberg, Simon Peyton Jones, and Stephanie Weirich. Safe zero-cost coercions for Haskell (extended version), Tech. Report MS-CIS-14-07, University of Pennsylvania, 2014.Google ScholarGoogle Scholar
  2. James Cheney and Ralf Hinze. First-class phantom types, Tech. report, Cornell University, 2003.Google ScholarGoogle Scholar
  3. Manuel M. T. Chakravarty, Gabriele Keller, and Simon Peyton Jones. Associated type synonyms, ICFP, ACM, 2005, pp. 241--253. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Manuel M. T. Chakravarty, Gabriele Keller, Simon Peyton Jones, and Simon Marlow. Associated types with class, POPL, ACM, 2005, pp. 1--13. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Richard A. Eisenberg, Dimitrios Vytiniotis, Simon Peyton Jones, and Stephanie Weirich. Closed type families with overlapping equations, POPL, ACM, 2014, pp. 671--683. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Jacques Garrigue. On variance, injectivity, and abstraction, OCaml Meeting, Boston., September 2013.Google ScholarGoogle Scholar
  7. Ralf Lämmel and Simon Peyton Jones. Scrap your boilerplate with class: Extensible generic functions, ICFP, 2005.Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Simon Marlow (editor). Haskell 2010 language report, 2010.Google ScholarGoogle Scholar
  9. Robin Milner, Mads Tofte, Robert Harper, and David MacQueen. The definition of Standard ML (revised), 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Simon Peyton Jones and J Launchbury. Unboxed values as first class citizens, FPCA, LNCS, vol. 523, 1991, pp. 636--666. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Simon Peyton Jones, Andrew Tolmach, and Tony Hoare. Playing by the rules: rewriting as a practical optimisation technique in GHC, Haskell Workshop, 2001, pp. 203--233.Google ScholarGoogle Scholar
  12. Gabriel Scherer and Didier Rémy. GADTs meet subtyping, ESOP, 2013, pp. 554--573. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Dimitrios Vytiniotis, Simon Peyton Jones, and José Pedro Magalhães. Equality proofs and deferred type errors: A compiler pearl, ICFP, ACM, 2012, pp. 341--352. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Philip Wadler and Stephen Blott. How to make ad-hoc polymorphism less ad-hoc, POPL, ACM, 1989, pp. 60--76. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Stephanie Weirich, Dimitrios Vytiniotis, Simon Peyton Jones, and Steve Zdancewic. Generative type abstraction and type-level computation, POPL, ACM, 2011, pp. 227--240. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Brent A. Yorgey, Stephanie Weirich, Julien Cretin, Simon Peyton Jones, Dimitrios Vytiniotis, and José Pedro Magalhães. Giving Haskell a promotion, TLDI, ACM, 2012, pp. 53--66. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Safe zero-cost coercions for Haskell

    Comments

    Login options

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

    Sign in

    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!