Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
10.1145/1411204.1411218acmconferencesArticle/Chapter ViewAbstractPublication PagesicfpConference Proceedingsconference-collections
research-article

A type-preserving compiler in Haskell

Published: 20 September 2008 Publication History
  • Get Citation Alerts
  • Abstract

    There has been a lot of interest of late for programming languages that incorporate features from dependent type systems and proof assistants, in order to capture important invariants of the program in the types. This allows type-based program verification and is a promising compromise between plain old types and full blown Hoare logic proofs. The introduction of GADTs in GHC (and more recently type families) made such dependent typing available in an industry-quality implementation, making it possible to consider its use in large scale programs.
    We have undertaken the construction of a complete compiler for System F, whose main property is that the GHC type checker verifies mechanically that each phase of the compiler properly preserves types. Our particular focus is on "types rather than proofs": reasonably few annotations that do not overwhelm the actual code.
    We believe it should be possible to write such a type-preserving compiler with an amount of extra code comparable to what is necessary for typical typed intermediate languages, but with the advantage of static checking. We will show in this paper the remaining hurdles to reach this goal.

    Supplementary Material

    index.html (index.html)
    Slides from the presentation
    ZIP File (p75-slides.zip)
    Supplemental material for: A type-preserving compiler in Haskell
    Audio only (1411218.mp3)
    Video (1411218.mp4)

    References

    [1]
    Sandrine Blazy, Zaynah Dargaye, and Xavier Leroy. Formal verification of a c compiler front-end. In International Symposium on Formal Methods, volume 4085 of Lecture Notes in Computer Science, pages 460--475, aug 2006.
    [2]
    Chiyan Chen and Hongwei Xi. Implementing typeful program transformations. In PEPM '03: Proceedings of the 2003 ACM SIGPLAN workshop on Partial evaluation and semantics-based program manipulation, pages 20--28, New York, NY, USA, 2003. ACM Press. ISBN 1-58113-667-6.
    [3]
    James Cheney and Ralf Hinze. First-class phantom types. Technical Report CUCIS TR2003-1901, Cornell University, 2003.
    [4]
    Adam Chlipala. A certified type-preserving compiler from lambda calculus to assembly language. In Symposium on Programming Languages Design and Implementation, pages 54--65. ACM Press, June 2007.
    [5]
    Adam Chlipala. Parametric higher-order abstract syntax for mechanized semantics. In International Conference on Functional Programming. ACM Press, September 2008.
    [6]
    Olivier Danvy and Andrzej Filinski. Representing control, a study of the CPS transformation. Mathematical Structures in Computer Science, 2 (4):361--391, 1992.
    [7]
    Leonidas Fegaras and Tim Sheard. Revisiting catamorphisms over datatypes with embedded functions (or, programs from outer space). In Conf. Record 23rd ACM SIGPLAN/SIGACT Symp. on Principles of Programming Languages, POPL'96, St. Petersburg Beach, FL, USA, 21-24 Jan. 1996, pages 284--294. ACM Press, New York, 1996.
    [8]
    Louis-Julien Guillemette and Stefan Monnier. Type-safe code transformations in Haskell. In Programming Languages meets Program Verification, volume 174(7) of Electronic Notes in Theoretical Computer Science, pages 23--39, August 2006.
    [9]
    Louis-Julien Guillemette and Stefan Monnier. A type-preserving closure conversion in Haskell. In Haskell Workshop. ACM Press, September 2007.
    [10]
    Louis-Julien Guillemette and Stefan Monnier. One vote for type families in Haskell! In The 9th symposium on Trends in Functional Programming, 2008.
    [11]
    Nadeem Abdul Hamid, Zhong Shao, Valery Trifonov, Stefan Monnier, and Zhaozhong Ni. A syntactic approach to foundational proof-carrying code. In Annual Symposium on Logic in Computer Science, pages 89--100, Copenhagen, Denmark, July 2002.
    [12]
    Fairouz Kamareddine. Reviewing the classical and the de bruijn notation for λ-calculus and pure type systems. Journal of Logic and Computation, 11, 2001.
    [13]
    Xavier Leroy. Formal certification of a compiler back-end or: programming a compiler with a proof assistant. In Symposium on Principles of Programming Languages, pages 42--54, New York, NY, USA, January 2006. ACM Press. ISBN 1-59593-027-2.
    [14]
    Nathan Linger and Tim Sheard. Programming with static invariants in Omega. Unpublished, 2004.
    [15]
    Yasuhiko Minamide, Greg Morrisett, and Robert Harper. Typed closure conversion. In POPL '96: Proceedings of the 23rd ACM SIGPLANSIGACT symposium on Principles of programming languages, pages 271--283, New York, NY, USA, 1996. ACM. ISBN 0-89791-769-3.
    [16]
    Greg Morrisett, David Walker, Karl Crary, and Neal Glew. From system F to typed assembly language. ACM Transactions on Programming Languages and Systems, 21(3):527--568, 1999.
    [17]
    George C. Necula. Proof-carrying code. In Conference Record of POPL '97: The 24th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pages 106--119, Paris, France, jan 1997.
    [18]
    Emir Pasalic. The Role of Type Equality in Meta-Programming. PhD thesis, Oregon Health and Sciences University, The OGI School of Science and Engineering, 2004.
    [19]
    Simon Peyton-Jones et al. The Haskell Prime Report. Working Draft, 2007.
    [20]
    Brigitte Pientka. A type-theoretic foundation for programming with higherorder abstract syntax and first-class substitutions. In Symposium on Principles of Programming Languages, pages 371--382, 2008.
    [21]
    Brigitte Pientka and Joshua Dunfield. Programming with proofs and explicit contexts. In Symposium on Principles and Practice of Declarative Programming, 2008.
    [22]
    François Pottier and Nadji Gauthier. Polymorphic typed defunctionalization. SIGPLAN Not., 39(1):89--98, 2004. ISSN 0362-1340.
    [23]
    Tom Schrijvers, Martin Sulzmann, Simon Peyton Jones, and Manuel M. T. Chakravarty. Towards open type functions for Haskell. Presented at IFL 2007, 2007.
    [24]
    Zhong Shao. An overview of the FLINT/ML compiler. In International Workshop on Types in Compilation, June 1997.
    [25]
    Zhong Shao and Andrew W. Appel. A type-based compiler for Standard ML. In Symposium on Programming Languages Design and Implementation, pages 116--129, La Jolla, CA, June 1995. ACM Press.
    [26]
    Zhong Shao, Bratin Saha, Valery Trifonov, and Nikolaos Papaspyrou. A type system for certified binaries. In Symposium on Principles of Programming Languages, pages 217--232, January 2002.
    [27]
    Tim Sheard and Simon Peyton Jones. Template meta-programming for Haskell. In Haskell '02: Proceedings of the 2002 ACM SIGPLAN workshop on Haskell, pages 1--16, New York, NY, USA, 2002. ACM Press. ISBN 1-58113-605-6.
    [28]
    Martin Sulzmann, Manuel M. T. Chakravarty, Simon Peyton Jones, and Kevin Donnelly. System F with type equality coercions. In Types in Language Design and Implementation, January 2007.
    [29]
    David Tarditi, Greg Morrisett, Perry Cheng, Christopher Stone, Robert Harper, and Peter Lee. TIL: A type-directed optimizing compiler for ML. In Symposium on Programming Languages Design and Implementation, pages 181--192, Philadelphia, PA, May 1996. ACM Press.
    [30]
    Geoffrey Washburn and Stephanie Weirich. Boxes go bananas: Encoding higher-order abstract syntax with parametric polymorphism. In Proceedings of the Eighth ACM SIGPLAN International Conference on Functional Programming, pages 249--262, Uppsala, Sweden, August 2003. ACM SIGPLAN.
    [31]
    Hongwei Xi, Chiyan Chen, and Gang Chen. Guarded recursive datatype constructors. In Symposium on Principles of Programming Languages, pages 224--235, New Orleans, LA, January 2003.

    Cited By

    View all
    • (2023)Defunctionalization with Dependent TypesProceedings of the ACM on Programming Languages10.1145/35912417:PLDI(516-538)Online publication date: 6-Jun-2023
    • (2022)How to safely use extensionality in Liquid HaskellProceedings of the 15th ACM SIGPLAN International Haskell Symposium10.1145/3546189.3549919(13-26)Online publication date: 6-Sep-2022
    • (2021)Intrinsically typed compilation with nameless labelsProceedings of the ACM on Programming Languages10.1145/34343035:POPL(1-28)Online publication date: 4-Jan-2021
    • Show More Cited By

    Recommendations

    Comments

    Information & Contributors

    Information

    Published In

    cover image ACM Conferences
    ICFP '08: Proceedings of the 13th ACM SIGPLAN international conference on Functional programming
    September 2008
    422 pages
    ISBN:9781595939197
    DOI:10.1145/1411204
    • cover image ACM SIGPLAN Notices
      ACM SIGPLAN Notices  Volume 43, Issue 9
      ICFP '08
      September 2008
      399 pages
      ISSN:0362-1340
      EISSN:1558-1160
      DOI:10.1145/1411203
      Issue’s Table of Contents
    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]

    Sponsors

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    Published: 20 September 2008

    Permissions

    Request permissions for this article.

    Check for updates

    Author Tags

    1. compilation
    2. de Bruijn
    3. higher-order abstract syntax
    4. typed assembly language

    Qualifiers

    • Research-article

    Conference

    ICFP08
    Sponsor:

    Acceptance Rates

    Overall Acceptance Rate 333 of 1,064 submissions, 31%

    Upcoming Conference

    ICFP '24

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • Downloads (Last 12 months)12
    • Downloads (Last 6 weeks)2

    Other Metrics

    Citations

    Cited By

    View all
    • (2023)Defunctionalization with Dependent TypesProceedings of the ACM on Programming Languages10.1145/35912417:PLDI(516-538)Online publication date: 6-Jun-2023
    • (2022)How to safely use extensionality in Liquid HaskellProceedings of the 15th ACM SIGPLAN International Haskell Symposium10.1145/3546189.3549919(13-26)Online publication date: 6-Sep-2022
    • (2021)Intrinsically typed compilation with nameless labelsProceedings of the ACM on Programming Languages10.1145/34343035:POPL(1-28)Online publication date: 4-Jan-2021
    • (2020)Stitch: the sound type-indexed type checker (functional pearl)Proceedings of the 13th ACM SIGPLAN International Symposium on Haskell10.1145/3406088.3409015(39-53)Online publication date: 27-Aug-2020
    • (2017)Parallel functional arraysACM SIGPLAN Notices10.1145/3093333.300986952:1(706-718)Online publication date: 1-Jan-2017
    • (2017)Typed self-evaluation via intensional type functionsACM SIGPLAN Notices10.1145/3093333.300985352:1(415-428)Online publication date: 1-Jan-2017
    • (2017)Typed self-evaluation via intensional type functionsProceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages10.1145/3009837.3009853(415-428)Online publication date: 1-Jan-2017
    • (2016)A Reflection on TypesA List of Successes That Can Change the World10.1007/978-3-319-30936-1_16(292-317)Online publication date: 25-Mar-2016
    • (2015)Type-safe runtime code generation: accelerate to LLVMACM SIGPLAN Notices10.1145/2887747.280431350:12(201-212)Online publication date: 30-Aug-2015
    • (2015)Type-safe runtime code generation: accelerate to LLVMProceedings of the 2015 ACM SIGPLAN Symposium on Haskell10.1145/2804302.2804313(201-212)Online publication date: 30-Aug-2015
    • Show More Cited By

    View Options

    Get Access

    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