skip to main content
10.1145/2628136.2628141acmconferencesArticle/Chapter ViewAbstractPublication PagesicfpConference Proceedingsconference-collections
research-article

Safe zero-cost coercions for Haskell

Published: 19 August 2014 Publication 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.
[2]
James Cheney and Ralf Hinze. First-class phantom types, Tech. report, Cornell University, 2003.
[3]
Manuel M. T. Chakravarty, Gabriele Keller, and Simon Peyton Jones. Associated type synonyms, ICFP, ACM, 2005, pp. 241--253.
[4]
Manuel M. T. Chakravarty, Gabriele Keller, Simon Peyton Jones, and Simon Marlow. Associated types with class, POPL, ACM, 2005, pp. 1--13.
[5]
Richard A. Eisenberg, Dimitrios Vytiniotis, Simon Peyton Jones, and Stephanie Weirich. Closed type families with overlapping equations, POPL, ACM, 2014, pp. 671--683.
[6]
Jacques Garrigue. On variance, injectivity, and abstraction, OCaml Meeting, Boston., September 2013.
[7]
Ralf Lämmel and Simon Peyton Jones. Scrap your boilerplate with class: Extensible generic functions, ICFP, 2005.
[8]
Simon Marlow (editor). Haskell 2010 language report, 2010.
[9]
Robin Milner, Mads Tofte, Robert Harper, and David MacQueen. The definition of Standard ML (revised), 1997.
[10]
Simon Peyton Jones and J Launchbury. Unboxed values as first class citizens, FPCA, LNCS, vol. 523, 1991, pp. 636--666.
[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.
[12]
Gabriel Scherer and Didier Rémy. GADTs meet subtyping, ESOP, 2013, pp. 554--573.
[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.
[14]
Philip Wadler and Stephen Blott. How to make ad-hoc polymorphism less ad-hoc, POPL, ACM, 1989, pp. 60--76.
[15]
Stephanie Weirich, Dimitrios Vytiniotis, Simon Peyton Jones, and Steve Zdancewic. Generative type abstraction and type-level computation, POPL, ACM, 2011, pp. 227--240.
[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.

Cited By

View all
  • (2022)The Foil: Capture-Avoiding Substitution With No Sharp EdgesProceedings of the 34th Symposium on Implementation and Application of Functional Languages10.1145/3587216.3587224(1-10)Online publication date: 31-Aug-2022
  • (2020)Short Paper: Weak Runtime-Irrelevant Typing for SecurityProceedings of the 15th Workshop on Programming Languages and Analysis for Security10.1145/3411506.3417595(13-17)Online publication date: 13-Nov-2020
  • (2019)First-Class SubtypesElectronic Proceedings in Theoretical Computer Science10.4204/EPTCS.294.4294(74-85)Online publication date: 16-May-2019
  • Show More Cited By

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM Conferences
ICFP '14: Proceedings of the 19th ACM SIGPLAN international conference on Functional programming
August 2014
390 pages
ISBN:9781450328739
DOI:10.1145/2628136
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 the author(s) 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].

Sponsors

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 19 August 2014

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. coercion
  2. haskell
  3. newtype deriving
  4. type class

Qualifiers

  • Research-article

Funding Sources

Conference

ICFP'14
Sponsor:

Acceptance Rates

ICFP '14 Paper Acceptance Rate 28 of 85 submissions, 33%;
Overall Acceptance Rate 333 of 1,064 submissions, 31%

Upcoming Conference

ICFP '25
ACM SIGPLAN International Conference on Functional Programming
October 12 - 18, 2025
Singapore , Singapore

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)3
  • Downloads (Last 6 weeks)0
Reflects downloads up to 13 Dec 2024

Other Metrics

Citations

Cited By

View all
  • (2022)The Foil: Capture-Avoiding Substitution With No Sharp EdgesProceedings of the 34th Symposium on Implementation and Application of Functional Languages10.1145/3587216.3587224(1-10)Online publication date: 31-Aug-2022
  • (2020)Short Paper: Weak Runtime-Irrelevant Typing for SecurityProceedings of the 15th Workshop on Programming Languages and Analysis for Security10.1145/3411506.3417595(13-17)Online publication date: 13-Nov-2020
  • (2019)First-Class SubtypesElectronic Proceedings in Theoretical Computer Science10.4204/EPTCS.294.4294(74-85)Online publication date: 16-May-2019
  • (2019)Dependently typed Haskell in industry (experience report)Proceedings of the ACM on Programming Languages10.1145/33417043:ICFP(1-16)Online publication date: 26-Jul-2019
  • (2019)Modular effects in Haskell through effect polymorphism and explicit dictionary applications: a new approach and the μVeriFast verifier as a case studyProceedings of the 12th ACM SIGPLAN International Symposium on Haskell10.1145/3331545.3342589(1-14)Online publication date: 8-Aug-2019
  • (2018)Coherent explicit dictionary application for HaskellACM SIGPLAN Notices10.1145/3299711.324275253:7(81-93)Online publication date: 17-Sep-2018
  • (2018)Deriving via: or, how to turn hand-written instances into an anti-patternACM SIGPLAN Notices10.1145/3299711.324274653:7(55-67)Online publication date: 17-Sep-2018
  • (2018)Coherent explicit dictionary application for HaskellProceedings of the 11th ACM SIGPLAN International Symposium on Haskell10.1145/3242744.3242752(81-93)Online publication date: 17-Sep-2018
  • (2018)Deriving via: or, how to turn hand-written instances into an anti-patternProceedings of the 11th ACM SIGPLAN International Symposium on Haskell10.1145/3242744.3242746(55-67)Online publication date: 17-Sep-2018
  • (2017)A specification for dependent types in HaskellProceedings of the ACM on Programming Languages10.1145/31102751:ICFP(1-29)Online publication date: 29-Aug-2017
  • Show More Cited By

View Options

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media