skip to main content
article

The Thoralf plugin: for your fancy type needs

Published:17 September 2018Publication History
Skip Abstract Section

Abstract

Many fancy types (e.g., generalized algebraic data types, type families) require a type checker plugin. These fancy types have a type index (e.g., type level natural numbers) with an equality relation that is difficult or impossible to represent using GHC's built-in type equality. The most practical way to represent these equality relations is through a plugin that asserts equality constraints. However, such plugins are difficult to write and reason about.

In this paper, we (1) present a formal theory of reasoning about the correctness of type checker plugins for type indices, and, (2) apply this theory in creating Thoralf, a generic and extensible plugin for type indices that translates GHC constraint problems to queries to an external SMT solver. By "generic and extensible", we mean the restrictions on extending Thoralf are slight, and, if some type index could be encoded as an SMT sort, then a programmer could extend Thoralf by providing this encoding function.

References

  1. Joachim Breitner, Richard A. Eisenberg, Simon Peyton Jones, and Stephanie Weirich. 2016. Safe Zero-cost Coercions for Haskell. J. Funct. Program. 26 (2016), 1–79.Google ScholarGoogle ScholarCross RefCross Ref
  2. Manuel M. T. Chakravarty, Gabriele Keller, and Simon Peyon Jones. 2005. Associated Type Synonyms. In International Conference on Functional Programming (ICFP ’05). ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Leonardo de Moura and Nikolaj Bjørner. 2008. Z3: An Efficient SMT Solver. In Tools and Algorithms for the Construction and Analysis of Systems, C. R. Ramakrishnan and Jakob Rehof (Eds.). Springer Berlin Heidelberg, Berlin, Heidelberg, 337–340. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Leonardo de Moura and Nikolaj Bjørner. 2009. Generalized, efficient array decision procedures. In 2009 Formal Methods in Computer-Aided Design. 45–52.Google ScholarGoogle Scholar
  5. Iavor S. Diatchki. 2015. Improving Haskell Types with SMT. In Proceedings of the 2015 ACM SIGPLAN Symposium on Haskell (Haskell ’15). ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Richard A. Eisenberg and Jan Stolarek. 2014. Promoting Functions to Type Families in Haskell. In ACM SIGPLAN Haskell Symposium. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Richard A. Eisenberg, Dimitrios Vytiniotis, Simon Peyton Jones, and Stephanie Weirich. 2014. Closed Type Families with Overlapping Equations. In Principles of Programming Languages (POPL ’14). ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Richard A. Eisenberg and Stephanie Weirich. 2012. Dependently Typed Programming with Singletons. In ACM SIGPLAN Haskell Symposium. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Adam Gundry. 2015. A Typechecker Plugin for Units of Measure: Domain-specific Constraint Solving in GHC Haskell. In Proceedings of the 2015 ACM SIGPLAN Symposium on Haskell (Haskell ’15). ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Georgios Karachalias, Tom Schrijvers, Dimitrios Vytiniotis, and Simon Peyton Jones. 2015. GADTs meet their match. In International Conference on Functional Programming (ICFP ’15). ACM.Google ScholarGoogle Scholar
  11. John McCarthy. 1962. Towards a mathematical science of computation. In IFIP Congress. 21–28.Google ScholarGoogle Scholar
  12. Stefan Monnier and David Haguenauer. 2010. Singleton types here, singleton types there, singleton types everywhere. In Programming languages meets program verification (PLPV ’10). ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Takayuki Muranushi and Richard A. Eisenberg. 2014. Experience Report: Type-checking Polymorphic Units for Astrophysics Research in Haskell. In ACM SIGPLAN Haskell Symposium. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Atze van der Ploeg, Koen Claessen, and Pablo Buiras. 2016. The Key Monad: Type-safe Unconstrained Dynamic Typing. In Proceedings of the 9th International Symposium on Haskell (Haskell 2016). ACM, New York, NY, USA. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Aaron Stump, Clark W. Barrett, David L. Dill, and Jeremy Levitt. 2001. A decision procedure for an extensional theory of arrays. In Proceedings 16th Annual IEEE Symposium on Logic in Computer Science. 29–37. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Dimitrios Vytiniotis, Simon Peyton Jones, Tom Schrijvers, and Martin Sulzmann. 2011. OutsideIn(X): Modular Type Inference with Local Assumptions. Journal of Functional Programming 21, 4-5 (Sept. 2011). Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. The Thoralf plugin: for your fancy type needs

      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 53, Issue 7
        Haskell '18
        July 2018
        185 pages
        ISSN:0362-1340
        EISSN:1558-1160
        DOI:10.1145/3299711
        Issue’s Table of Contents
        • cover image ACM Conferences
          Haskell 2018: Proceedings of the 11th ACM SIGPLAN International Symposium on Haskell
          September 2018
          185 pages
          ISBN:9781450358354
          DOI:10.1145/3242744

        Copyright © 2018 ACM

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 17 September 2018

        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!