## Generative Type Abstraction and Type-level Computation (Extended Version)

### Cached

### Download Links

Citations: | 16 - 9 self |

### BibTeX

@MISC{Weirich_generativetype,

author = {Stephanie Weirich and Dimitrios Vytiniotis and Simon Peyton Jones and Steve Zdancewic},

title = {Generative Type Abstraction and Type-level Computation (Extended Version)},

year = {}

}

### OpenURL

### Abstract

Modular languages support generative type abstraction, ensuring that an abstract type is distinct from its representation, except inside the implementation where the two are synonymous. We show that this well-established feature is in tension with the non-parametric features of newer type systems, such as indexed type families and GADTs. In this paper we solve the problem by using kinds to distinguish between parametric and non-parametric contexts. The result is directly applicable to Haskell, which is rapidly developing support for type-level computation, but the same issues should arise whenever generativity and non-parametric features are combined.

### Citations

267 | Compiling polymorphism using intensional type analysis
- HARPER, MORRISETT
- 1995
(Show Context)
Citation Context ...er types. However, such facility is often necessary to describe the type of generic programs. For example, Harper and Morrisett include a Typerec operator to their typed intermediate language λ ML i [=-=Harper and Morrisett 1995-=-], to describe type-directed optimizations. (They credit NuPRL’s mechanism of “Universe Elimination” in NuPRL as the inspiration for this operation [Constable 1982; Constable and Zlatin 1984].) To sup... |

168 | An intuitionistic theory of types: Predicative part - Martin-Löf - 1975 |

165 | Simple unification-based type inference for GADTs
- Vytiniotis, Weirich, et al.
(Show Context)
Citation Context ...ects not only type-level non-parametric functions, but also other forms of non-parametric constructs, such as generalized algebraic datatypes (GADTs) [Cheney and Hinze 2003; Hinze et al. 2002; Peyton =-=Jones et al. 2006-=-; Xi et al. 2003]. • We formalize a solution to this problem that reconciles flexible type generativity and non-parametric type functions in Section 3. Our language, FC2, builds on GHC’s existing core... |

135 | Guarded recursive datatype constructors
- Xi, Chen, et al.
- 2003
(Show Context)
Citation Context ...level non-parametric functions, but also other forms of non-parametric constructs, such as generalized algebraic datatypes (GADTs) [Cheney and Hinze 2003; Hinze et al. 2002; Peyton Jones et al. 2006; =-=Xi et al. 2003-=-]. • We formalize a solution to this problem that reconciles flexible type generativity and non-parametric type functions in Section 3. Our language, FC2, builds on GHC’s existing core language, Syste... |

129 | Type classes in Haskell
- Hall, Hammond, et al.
- 1996
(Show Context)
Citation Context ...s, whereas to the client of the module the two types are completely distinct. There is growing interest in languages that support some form of type-level computation including Haskell’s type classes [=-=Hall et al. 1996-=-] and indexed type families [Kiselyov et al. 2010]. However, there is a fundamental tension between type-level computation and generative type abstraction, at least in the latter’s more flexible forms... |

123 | Inheritance as implicit coercion
- Breazu-Tannen, Coquand, et al.
- 1991
(Show Context)
Citation Context ...ulzmann et al. 2007] discusses a significant amount of related work, in typed languages with explicit proof witnesses [Licata and Harper 2005; Shao et al. 2005], or in calculi that support coercions [=-=Breazu-Tannen et al. 1991-=-]. Below, we present related work in generativity and abstraction, typeindexed constructs and the separation between codes and types. Generativity, abstraction, and module systems Generativity and abs... |

109 | First-class phantom types
- Cheney, Hinze
- 2003
(Show Context)
Citation Context ...anifests in the Glasgow Haskell Compiler, and affects not only type-level non-parametric functions, but also other forms of non-parametric constructs, such as generalized algebraic datatypes (GADTs) [=-=Cheney and Hinze 2003-=-; Hinze et al. 2002; Peyton Jones et al. 2006; Xi et al. 2003]. • We formalize a solution to this problem that reconciles flexible type generativity and non-parametric type functions in Section 3. Our... |

85 | A type system for certified binaries
- Shao, Trifonov, et al.
- 2005
(Show Context)
Citation Context ...erleavings. 7. Related work Previous work on System FC [Sulzmann et al. 2007] discusses a significant amount of related work, in typed languages with explicit proof witnesses [Licata and Harper 2005; =-=Shao et al. 2005-=-], or in calculi that support coercions [Breazu-Tannen et al. 1991]. Below, we present related work in generativity and abstraction, typeindexed constructs and the separation between codes and types. ... |

81 | Associated types with class - Chakravarty, Keller, et al. - 2005 |

80 | Flexible type analysis
- CRARY, WEIRICH
- 1999
(Show Context)
Citation Context ...initions and interpretations of codes. To better support generic programming, the dependently-typed language Epigram [Chapman et al. 2010] identifies types with their code universes. The LX language [=-=Crary and Weirich 1999-=-] also uses universe constructions to solve problems with type-directed compilation. When the type translation in a compiler pass is not the identity then type dispatch must be compiled to code dispat... |

79 | Associated type synonyms - Chakravarty, Keller, et al. - 2005 |

66 | A general formulation of simultaneous inductive-recursive definitions in type theory - Dybjer |

62 | et al. The Haskell 98 language and libraries: The revised report - Jones - 2003 |

43 | Universes for generic programs and proofs in dependent type theory - Benke, Dybjer, et al. |

43 | Generativity and dynamic opacity for abstract types
- Rossberg
- 2003
(Show Context)
Citation Context ...nection by introducing “open” existential types. Rossberg [2008] uses flexible generativity to explain ML-style module sealing. Type abstraction can be understood in terms of dynamic name generation [=-=Rossberg 2003-=-; Vytiniotis et al. 2005], which can reestablish abstraction properties in languages with dynamic type analysis. Neis et al. [2009] prove a parametricity theorem in this setting. In addition, they use... |

41 | Type checking with open type functions
- Schrijvers, Jones, et al.
- 2008
(Show Context)
Citation Context ...ances associated with type class instances. Currently, the source language of GHC also supports standalone type-level type functions, often referred to as indexed type families [Kiselyov et al. 2010; =-=Schrijvers et al. 2008-=-], a feature that we have extensively used in our presentation. Codes, types, and interpretations Our distinction between codes and types—and our terminology—is inspired by similar notions in intuitio... |

27 | Recursive type generativity - Dreyer - 2005 |

26 | A formulation of Dependent ML with explicit equality proofs
- Licata, Harper
- 2005
(Show Context)
Citation Context ...opes allow arbitrary interleavings. 7. Related work Previous work on System FC [Sulzmann et al. 2007] discusses a significant amount of related work, in typed languages with explicit proof witnesses [=-=Licata and Harper 2005-=-; Shao et al. 2005], or in calculi that support coercions [Breazu-Tannen et al. 1991]. Below, we present related work in generativity and abstraction, typeindexed constructs and the separation between... |

23 | A Brief Overview of Agda — A Functional Language with Dependent Types
- Bove, Dybjer, et al.
- 2009
(Show Context)
Citation Context ... giving rise to a new code, inhabiting an open universe of codes, and whose interpretation coincides with the interpretation of its definition. Languages based on dependent type theory, such as Agda [=-=Bove et al. 2009-=-] or Coq [The Coq Team], naturally offer type-level computation to construct types, but they allow elimination of codes only, not types. Therefore, they do not exhibit the same soundness problem, as t... |

23 | The gentle art of levitation
- Chapman, Dagand, et al.
- 2010
(Show Context)
Citation Context ...pes and codes. The disadvantage is the extra programming verbosity of explicit definitions and interpretations of codes. To better support generic programming, the dependently-typed language Epigram [=-=Chapman et al. 2010-=-] identifies types with their code universes. The LX language [Crary and Weirich 1999] also uses universe constructions to solve problems with type-directed compilation. When the type translation in a... |

18 | An open and shut typecase
- Vytiniotis, Washburn, et al.
- 2005
(Show Context)
Citation Context ...oducing “open” existential types. Rossberg [2008] uses flexible generativity to explain ML-style module sealing. Type abstraction can be understood in terms of dynamic name generation [Rossberg 2003; =-=Vytiniotis et al. 2005-=-], which can reestablish abstraction properties in languages with dynamic type analysis. Neis et al. [2009] prove a parametricity theorem in this setting. In addition, they use a translation from poly... |

17 |
The type theory of PL/CV3
- Constable, Zlatin
- 1984
(Show Context)
Citation Context ...e λ ML i [Harper and Morrisett 1995], to describe type-directed optimizations. (They credit NuPRL’s mechanism of “Universe Elimination” in NuPRL as the inspiration for this operation [Constable 1982; =-=Constable and Zlatin 1984-=-].) To support generic programming in source languages, Hinze, Jeuring and Löh added Type-Indexed Datatypes [Hinze et al. 2002] to the Generic Haskell front end. In later work, Chakravarty et al. [200... |

16 | Non-dependent types for Standard ML modules
- RUSSO
- 1999
(Show Context)
Citation Context ...ivity and abstraction has been studied extensively in the context of ML module systems [Milner et al. 1997]. Russo shows how generativity in module systems is connected to existential quantification [=-=Russo 1999-=-] and Dreyer [2005] has studied this connection in the presence of recursive modules. Montagu and Rémy [2009] refine this connection by introducing “open” existential types. Rossberg [2008] uses flexi... |

14 | Modeling abstract types in modules with open existential types - MONTAGU, RÉMY - 2009 |

13 | Non-parametric parametricity - Neis, Dreyer, et al. - 2009 |

9 |
Intensional analysis of functions and types
- Constable
- 1982
(Show Context)
Citation Context ...rmediate language λ ML i [Harper and Morrisett 1995], to describe type-directed optimizations. (They credit NuPRL’s mechanism of “Universe Elimination” in NuPRL as the inspiration for this operation [=-=Constable 1982-=-; Constable and Zlatin 1984].) To support generic programming in source languages, Hinze, Jeuring and Löh added Type-Indexed Datatypes [Hinze et al. 2002] to the Generic Haskell front end. In later wo... |

6 | Fun with type functions
- Kiselyov, Jones, et al.
- 2010
(Show Context)
Citation Context ...o types are completely distinct. There is growing interest in languages that support some form of type-level computation including Haskell’s type classes [Hall et al. 1996] and indexed type families [=-=Kiselyov et al. 2010-=-]. However, there is a fundamental tension between type-level computation and generative type abstraction, at least in the latter’s more flexible forms. To summarize very briefly, the conflict is this... |

4 | Dynamic translucency with abstraction kinds and higher-order coercions - Rossberg - 2008 |

2 | with type equality coercions - System - 2007 |

1 | bnd} a[a ↦→ γ] = γi when ai in a b[a ↦→ γ] = b when b ̸∈ a H [a ↦→ γ] = H (ϕ ψ)[a ↦→ γ] = (ϕ[a ↦→ γ]) (ψ[a ↦→ γ]) (∀b :κ.σ)[a ↦→ γ] = ∀b :κ.(σ[a ↦→ γ]) Γ ⊢ {a:κ - unknown authors |

1 | Proof We prove this by induction on the size of ϕ. We proceed by inversion on the rules used to deduce that Γ ⊢ ϕ � ϕ1 ∈ κ and Γ ⊢ ϕ � ϕ2 ∈ κ. Most of the cases are straightforward, and follow by the induction hypothesis, except for two combinations: • Ca - e |