717 research outputs found
An Overabundance of Equality: Implementing Kind Equalities into Haskell
Haskell, as embodied by version 7.10.1 of the Glasgow Haskell Compiler (GHC), supports reasoning about equality among types, via generalized algebraic datatypes (GADTs) and type families. However, these features are not available among the kinds that clas- sify the types. Motivated by a concrete example of how kind equali- ties can help programmers today, this paper presents the challenges and solutions encountered in integrating kind equalities into GHC, an industrial-strength compiler. The challenges addressed here all surround the many notions of type equality that exist in GHC to- day, and in particular around GHCâs role mechanism. These many different relations on types complicate the theory considerably
An update of GHC supporting reasoning about kind equalities is a key part of this work
An Overabundance of Equality: Implementing Kind Equalities into Haskell
Haskell, as embodied by version 7.10.1 of the Glasgow Haskell Compiler (GHC), supports reasoning about equality among types, via generalized algebraic datatypes (GADTs) and type families. However, these features are not available among the kinds that clas- sify the types. Motivated by a concrete example of how kind equali- ties can help programmers today, this paper presents the challenges and solutions encountered in integrating kind equalities into GHC, an industrial-strength compiler. The challenges addressed here all surround the many notions of type equality that exist in GHC to- day, and in particular around GHCâs role mechanism. These many different relations on types complicate the theory considerably
An update of GHC supporting reasoning about kind equalities is a key part of this work
Promoting Functions to Type Families in Haskell (extended version)
Haskell, as implemented in the Glasgow Haskell Compiler (GHC), is enriched with many extensions that support type-level programming, such as promoted datatypes, kind polymorphism, and type families. Yet, the expressiveness of the type-level language remains limited. It is missing many features present at the term level, including case expressions, anonymous functions, partially-applied functions, and let expressions. In this paper, we present an algorithm â with a proof of correctness â to encode these term-level constructs at the type level. Our approach is automated and capable of promoting a wide array of functions to type families.We also highlight and discuss those term-level features that are not promotable. In so doing, we offer a critique on GHCâs existing type system, showing what it is already capable of and where it may want improvement. We believe that delineating the mismatch between GHCâs term level and its type level is a key step toward supporting dependently typed programming.
We have implemented our approach as part of the singletons package, available online
Promoting Functions to Type Families in Haskell (extended version)
Haskell, as implemented in the Glasgow Haskell Compiler (GHC), is enriched with many extensions that support type-level programming, such as promoted datatypes, kind polymorphism, and type families. Yet, the expressiveness of the type-level language remains limited. It is missing many features present at the term level, including case expressions, anonymous functions, partially-applied functions, and let expressions. In this paper, we present an algorithm â with a proof of correctness â to encode these term-level constructs at the type level. Our approach is automated and capable of promoting a wide array of functions to type families.We also highlight and discuss those term-level features that are not promotable. In so doing, we offer a critique on GHCâs existing type system, showing what it is already capable of and where it may want improvement. We believe that delineating the mismatch between GHCâs term level and its type level is a key step toward supporting dependently typed programming.
We have implemented our approach as part of the singletons package, available online
Promoting Functions to Type Families in Haskell
Haskell, as implemented in the Glasgow Haskell Compiler (GHC), is enriched with many extensions that support type-level programming, such as promoted datatypes, kind polymorphism, and type families. Yet, the expressiveness of the type-level language remains limited. It is missing many features present at the term level, including case expressions, anonymous functions, partially-applied functions, and letexpressions. In this paper, we present an algorithm - with a proof of correctness - to encode these term-level constructs at the type level. Our approach is automated and capable of promoting a wide array of functions to type families. We also highlight and discuss those term-level features that are not promotable. In so doing, we offer a critique on GHC\u27s existing type system, showing what it is already capable of and where it may want improvement.
We believe that delineating the mismatch between GHC\u27s term level and its type level is a key step toward supporting dependently typed programming
The Thoralf Plugin: For Your Fancy Type Needs
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
Constrained Type Families
We present an approach to support partiality in type-level computation
without compromising expressiveness or type safety. Existing frameworks for
type-level computation either require totality or implicitly assume it. For
example, type families in Haskell provide a powerful, modular means of defining
type-level computation. However, their current design implicitly assumes that
type families are total, introducing nonsensical types and significantly
complicating the metatheory of type families and their extensions. We propose
an alternative design, using qualified types to pair type-level computations
with predicates that capture their domains. Our approach naturally captures the
intuitive partiality of type families, simplifying their metatheory. As
evidence, we present the first complete proof of consistency for a language
with closed type families.Comment: Originally presented at ICFP 2017; extended editio
- âŠ