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.
- 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 Scholar
Cross Ref
- Manuel M. T. Chakravarty, Gabriele Keller, and Simon Peyon Jones. 2005. Associated Type Synonyms. In International Conference on Functional Programming (ICFP ’05). ACM. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- Leonardo de Moura and Nikolaj Bjørner. 2009. Generalized, efficient array decision procedures. In 2009 Formal Methods in Computer-Aided Design. 45–52.Google Scholar
- Iavor S. Diatchki. 2015. Improving Haskell Types with SMT. In Proceedings of the 2015 ACM SIGPLAN Symposium on Haskell (Haskell ’15). ACM. Google Scholar
Digital Library
- Richard A. Eisenberg and Jan Stolarek. 2014. Promoting Functions to Type Families in Haskell. In ACM SIGPLAN Haskell Symposium. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- Richard A. Eisenberg and Stephanie Weirich. 2012. Dependently Typed Programming with Singletons. In ACM SIGPLAN Haskell Symposium. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
- John McCarthy. 1962. Towards a mathematical science of computation. In IFIP Congress. 21–28.Google Scholar
- 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 Scholar
Digital Library
- Takayuki Muranushi and Richard A. Eisenberg. 2014. Experience Report: Type-checking Polymorphic Units for Astrophysics Research in Haskell. In ACM SIGPLAN Haskell Symposium. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
Index Terms
The Thoralf plugin: for your fancy type needs
Recommendations
The Thoralf plugin: for your fancy type needs
Haskell 2018: Proceedings of the 11th ACM SIGPLAN International Symposium on HaskellMany 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 ...
A Lazy Language Needs a Lazy Type System: Introducing Polymorphic Contexts
IFL 2016: Proceedings of the 28th Symposium on the Implementation and Application of Functional Programming LanguagesMost type systems that support polymorphic functions are based on a version of System-F. We argue that this limits useful programming paradigms for languages with lazy evaluation. We motivate an extension of System-F alleviating this limitation.
First, ...
Supermonads: one notion to bind them all
Haskell '16Several popular generalizations of monads have been implemented in Haskell. Unfortunately, because the shape of the associated type constructors do not match the standard Haskell monad interface, each such implementation provides its own type class and ...







Comments