## System F with type equality coercions (2007)

### Cached

### Download Links

- [www.cse.unsw.edu.au]
- [research.microsoft.com]
- DBLP

### Other Repositories/Bibliography

Citations: | 73 - 25 self |

### BibTeX

@MISC{Sulzmann07systemf,

author = {Martin Sulzmann and Manuel M. T. Chakravarty and Simon Peyton Jones and Kevin Donnelly},

title = {System F with type equality coercions},

year = {2007}

}

### Years of Citing Articles

### OpenURL

### Abstract

We introduce System FC, which extends System F with support for non-syntactic type equality. There are two main extensions: (i) explicit witnesses for type equalities, and (ii) open, non-parametric type functions, given meaning by toplevel equality axioms. Unlike System F, FC is expressive enough to serve as a target for several different source-language features, including Haskell’s newtype, generalised algebraic data types, associated types, functional dependencies, and perhaps more besides.

### Citations

942 |
Term rewriting and all that
- Baader, Nipkow
- 1998
(Show Context)
Citation Context ...ions we seek. Reconstructing an equality proof amounts to unification modulo an equational theory (E-unification), which is undecidable even in various restricted forms, let alone in the general case =-=[2]-=-. In short, dropping the explicit proofs encoded by coercions would render type checking undecidable (see Appendix A for a formal proof). Why do we express coercions as types, rather than as terms? Do... |

704 | Types and Programming Languages - Pierce - 2002 |

696 | A Framework for Defining Logics
- Harper, Honsel, et al.
- 1993
(Show Context)
Citation Context ...calculi as they are used in theorem provers; e.g., based on the Calculus of Constructions [8]. Generally, our coercion terms are a simple instance of the proof terms of logical frameworks, such as LF =-=[16]-=-, or generally the evidence in intuitionistic type theory [22]. This connection indicates several directions for extending the presented system in the direction of more powerful dependently typed lang... |

342 |
Intuitionistic type theory
- Martin-Löf
- 1984
(Show Context)
Citation Context ...e Calculus of Constructions [8]. Generally, our coercion terms are a simple instance of the proof terms of logical frameworks, such as LF [18], or generally the evidence in intuitionistic type theory =-=[26]-=-. This connection indicates several directions for extending the presented system in the direction of more powerful dependently typed languages, such as Epigram [27]. Translucency and singleton kinds.... |

259 | Compiling Polymorphism Using Intensional Type Analysis
- Harper, Morrisett
- 1995
(Show Context)
Citation Context ...stem Fω can be found in [33], but this encoding only works for limited patterns of recursion. Intentional type analysis and beyond. Harper and Morrisett’s visionary paper on intensional type analysis =-=[20]-=- introduced the calculus λ ML i , which was already sufficiently expressive for a large range of GADT programs, although GADTs only became popular later. Subsequently, Crary and Weirch’s language LX [... |

218 |
Unification revisited
- Lassez, Maher, et al.
- 1986
(Show Context)
Citation Context ... other words, CO £ ��� � � � � � represents the GADT condition that the equality � “� context �£� � � ��� implies ”. Finding £ a is decidable, using an algorithm inspired by the unification algorithm =-=[20]-=-. The key observation is that the � statement ” holds if ��� � ��� � where � is the most � implies �£� � � �£� ��� � “� general unifier � of . W.l.o.g., we neglect the case � that has no unifier, � i.... |

157 | Simple unification-based type inference for GADTs
- Jones, Vytiniotis, et al.
- 2006
(Show Context)
Citation Context ...ediate language. But Haskell has incubated a variety of extensions that are hard to translate into this language: in particular, functional dependencies [18], generalised algebraic data types (GADTs) =-=[36, 27]-=-, and associated types [6, 5]. When we added GADTs to GHC, we also extended GHC’s intermediate language with GADTs as well, even though GADTs are arguably an over-sophisticated addition to a typed int... |

153 | Type Classes with Functional Dependencies
- Jones
- 2001
(Show Context)
Citation Context ...types and case-expressions, as its typed intermediate language. But Haskell has incubated a variety of extensions that are hard to translate into this language: in particular, functional dependencies =-=[18]-=-, generalised algebraic data types (GADTs) [36, 27], and associated types [6, 5]. When we added GADTs to GHC, we also extended GHC’s intermediate language with GADTs as well, even though GADTs are arg... |

153 |
The view from the left
- McBride, McKinna
(Show Context)
Citation Context ...ence in intuitionistic type theory [22]. This connection indicates several directions for extending the presented system in the direction of more powerful dependently typed languages, such as Epigram =-=[23]-=-. Shao et al. [30] use equalities for type conversion in a lambda calculus with a type language based on the calculus of inductive constructions to denote certified binaries. Interestingly, already GA... |

141 |
Intuitionistic Type Theory. Bibliopolis
- Martin-Löf
- 1984
(Show Context)
Citation Context ...e Calculus of Constructions [8]. Generally, our coercion terms are a simple instance of the proof terms of logical frameworks, such as LF [16], or generally the evidence in intuitionistic type theory =-=[22]-=-. This connection indicates several directions for extending the presented system in the direction of more powerful dependently typed languages, such as Epigram [23]. Shao et al. [30] use equalities f... |

129 | Guarded recursive datatype constructors
- Xi, Chen, et al.
- 2003
(Show Context)
Citation Context ...ediate language. But Haskell has incubated a variety of extensions that are hard to translate into this language: in particular, functional dependencies [18], generalised algebraic data types (GADTs) =-=[36, 27]-=-, and associated types [6, 5]. When we added GADTs to GHC, we also extended GHC’s intermediate language with GADTs as well, even though GADTs are arguably an over-sophisticated addition to a typed int... |

124 | A logic for parametric polymorphism
- Plotkin, Abadi
- 1993
(Show Context)
Citation Context ...ucture, which simplifies matters significantly. Moreover, this notation is justified by the logical structure of parametricity as captured in Abadi et al.’s logical relations between parametric types =-=[1]-=-. A well known instance of such a logical relation is the subsumption relation between parametric types, of which type equality is the symmetric closure. For example, we obviously have ��������� � �¡s... |

122 | Type classes in Haskell
- Hall, Hammond, et al.
- 1996
(Show Context)
Citation Context ... ¤� ¢ ������� ��� � � � �£��� ����������� � � � � � � � � � ¦ ��� � � � ��� ¢ � � ��� ������ ¤� ¢ ������� ��� � � � ¢ � � ����� � � �s���������� � Generally, type classes are translated into System F =-=[15]-=- by (1) turning each class into a record type, called a dictionary, containing the class methods, (2) converting each instance into a dictionary value, and (3) passing such dictionaries to whichever f... |

116 | Inheritance as implicit coercion
- Breazu-Tannen, Coquand, et al.
- 1991
(Show Context)
Citation Context ...] also studied coercions that are operationally identities to model type refinement for type inference in systems that go beyond Hindley/Milner. Much closer to � � is the work by Breazu-Tannen et al. =-=[4]-=- who add a notion of coercions to System F to translate languages featuring inheritance polymorphism. In contrast to ��� , their coercions model a subsumption relationship, not equalities, and their c... |

103 | First-class phantom types
- Cheney, Hinze
- 2003
(Show Context)
Citation Context ...���������� ������� ��������� So far, this is quite standard; indeed, several authors present GADTs in the source language using a syntax involving explicit equality constraints, similar to that above =-=[36, 10]-=-. However, for us the equality constraints are extra type arguments to the constructor, which must be given when the constructor is applied, and which are brought into scope by pattern matching. “� Th... |

102 | On the type structure of Standard ML
- Harper, Mitchell
- 1993
(Show Context)
Citation Context ...s are of kind � . The Rules (Var), (� -Intro), and (� -Elim), dealing with variables and the introduction and elimination of polymorphic types, are standard for translating Hindley/Milner to System F =-=[17]-=-. The introduction and elimination rules for constrained types, Rules (C-Intro) and (C-Elim), relate to the standard typeclass translation [15], but where class constraints induce value abstraction an... |

102 |
Polymorphic type inference and containment
- Mitchell
- 1988
(Show Context)
Citation Context ...coercion are not identities, but perform coercions between different numeric types and so forth. A more recent proposal of the same idea was presented by Kießling and Luo [19]. Subsequently, Mitchell =-=[24]-=- also studied coercions that are operationally identities to model type refinement for type inference in systems that go beyond Hindley/Milner. Much closer to � � is the work by Breazu-Tannen et al. [... |

83 | A type system for higher-order modules
- Dreyer, Crary, et al.
- 2003
(Show Context)
Citation Context ...rd [31] demonstrated. Translucency and singleton kinds. In the work on ML-style module systems, type equalities are represented as singleton kinds, which are essential to model translucent signatures =-=[13]-=-. Our use of equalities to represent programs that involve functional dependencies and existential types seems related. 7. Conclusions and further work We showed that explicit evidence for type equali... |

83 | A type system for certified binaries
- Shao, Trifonov, et al.
- 2005
(Show Context)
Citation Context ...stic type theory [22]. This connection indicates several directions for extending the presented system in the direction of more powerful dependently typed languages, such as Epigram [23]. Shao et al. =-=[30]-=- use equalities for type conversion in a lambda calculus with a type language based on the calculus of inductive constructions to denote certified binaries. Interestingly, already GADT equalities are ... |

76 | Associated types with class
- Chakravarty, Keller, et al.
(Show Context)
Citation Context ...s incubated a variety of extensions that are hard to translate into this language: in particular, functional dependencies [18], generalised algebraic data types (GADTs) [36, 27], and associated types =-=[6, 5]-=-. When we added GADTs to GHC, we also extended GHC’s intermediate language with GADTs as well, even though GADTs are arguably an over-sophisticated addition to a typed intermediate language. But when ... |

76 | Flexible Type Analysis
- Crary, Weirich
- 1999
(Show Context)
Citation Context ...ntic notion of what σ1 ∼ σ2 “means”. We use the symbol 6 “∼” rather than “=”, to avoid suggesting that the two types are intensionally equal. Coercions are types – some would call them “constructors” =-=[25, 12]-=- since they certainly do not have kind ⋆ — and hence the term-level syntax for type abstraction and application (Λa.e and e ϕ) also serves for coercion abstraction and application. However, coercions ... |

75 |
Associated type synonyms
- Chakravarty, Keller, et al.
- 2005
(Show Context)
Citation Context ...s incubated a variety of extensions that are hard to translate into this language: in particular, functional dependencies [18], generalised algebraic data types (GADTs) [36, 27], and associated types =-=[6, 5]-=-. When we added GADTs to GHC, we also extended GHC’s intermediate language with GADTs as well, even though GADTs are arguably an over-sophisticated addition to a typed intermediate language. But when ... |

75 | Recursive unsolvability of a problem of Thue - Post |

74 | A lightweight implementation of generics and dynamics
- Cheney, Hinze
- 2002
(Show Context)
Citation Context ... ��� � � � ����� � � assume ; � �����©��� £ � � then, is evidence � � � � � � that . Decomposition is necessary for the translation of GADT programs � � to , but was problematic in earlier approaches =-=[3, 9]-=-. The soundness of decomposition relies, of course, on algebraic types being injective; � ����� ��� � � ����� � � i.e., ��� � � � iff . Notice, too, � ����� that by itself is a coercion relating two t... |

71 |
Coercion and type inference
- Mitchell
- 1984
(Show Context)
Citation Context ...ndix A. An encoding of a restricted subset of GADT programs in plain System F§ can be found in [28], but this encoding only works for limited patterns of recursion. Coercion-based subtyping. Mitchell =-=[25]-=- introduced the idea of inserting coercions during type inference for an ML-like languages. However, Mitchell’s coercion are not identities, but perform coercions between different numeric types and s... |

69 | Languages of the future
- Sheard
- 2004
(Show Context)
Citation Context ...ages (notably Haskell) have started to explore language features that embody non-syntactic type equality. These features include functional dependencies [14], generalised algebraic data types (GADTs) =-=[36, 31]-=-, and associated types [6, 5]. All three are difficult or impossible to translate into System F — and yet the alternative of simply extending System F by adding functional dependencies, GADTs, and ass... |

61 | Polymorphic type inference and abstract data types
- Läufer, Odersky
- 1994
(Show Context)
Citation Context ...ing algebraic data types, data constructors, and ������� expressions. We will use ��� to describe System F extended in this way, where the data constructors are allowed to have existential components =-=[21]-=-, type variables can be of higher kind, and type constructor applications can be partial. 1 2006/7/28sOver the last few years, source languages (notably Haskell) have started to explore language featu... |

57 | Typing dynamic typing
- Baars, Swierstra
- 2002
(Show Context)
Citation Context ... ��� � � � ����� � � assume ; � �����©��� £ � � then, is evidence � � � � � � that . Decomposition is necessary for the translation of GADT programs � � to , but was problematic in earlier approaches =-=[3, 9]-=-. The soundness of decomposition relies, of course, on algebraic types being injective; � ����� ��� � � ����� � � i.e., ��� � � � iff . Notice, too, � ����� that by itself is a coercion relating two t... |

51 | Handbook of Theoretical Computer Science, volume B: Formal Models and Semantics, chapter 6: Rewrite Systems - Dershowitz, Jouannaud - 1990 |

44 | Fully reflexive intensional type analysis
- Trifonov, Saha, et al.
- 2000
(Show Context)
Citation Context ...ress closed type functions which must be primitive recursive. This is related, but different to FC(X), where type functions are open and need not be terminating (see also Appendix B). Trifonov et al. =-=[42]-=- generalised λ ML i in a different direction than LX, such that they arrived at a fully reflexive calculus; i.e., one that can analyse the type of any runtime value of the calculus. In particular, the... |

37 | Stratified type inference for generalized algebraic data types
- Pottier, Régis-Gianas
(Show Context)
Citation Context ... omit the coercions, retaining only their kinds, and reconstructing the proofs on the fly? No, we could not. Previous work showed that such proofs can indeed be inferred for the special case of GADTs =-=[36, 29]-=-. But our setting is much more general because of our type functions, which in turn are necessary to support the source-language extensions we seek. Reconstructing an equality proof amounts to unifica... |

32 | Sound and Decidable Type Inference for Functional Dependencies. Pages 49–63
- Duck, Jones, et al.
- 2004
(Show Context)
Citation Context ...2006/7/28sOver the last few years, source languages (notably Haskell) have started to explore language features that embody non-syntactic type equality. These features include functional dependencies =-=[14]-=-, generalised algebraic data types (GADTs) [36, 31], and associated types [6, 5]. All three are difficult or impossible to translate into System F — and yet the alternative of simply extending System ... |

31 | Type-safe cast: (functional pearl
- Weirich
- 2000
(Show Context)
Citation Context ... & Régis-Gianas’s MLGI [29]. This is the approach that GHC initially took. � � is the result of a search for an alternative. Encoding GADTs in plain System F and F§ . There are several previous works =-=[3, 9, 26, 35, 7, 33]-=- which attempt an encoding of GADTs in plain System F with (boxed) existential types. We believe that these primitive encoding schemes are not practical and often non-trivial to achieve. We discuss th... |

29 | Programming in higher-order typed lambda calculi
- Pierce, Dietzen, et al.
- 1989
(Show Context)
Citation Context ...coding schemes are not practical and often non-trivial to achieve. We discuss this in more detail in Appendix A. An encoding of a restricted subset of GADT programs in plain System F§ can be found in =-=[28]-=-, but this encoding only works for limited patterns of recursion. Coercion-based subtyping. Mitchell [25] introduced the idea of inserting coercions during type inference for an ML-like languages. How... |

25 | Typed compilation of inclusive subtyping
- Crary
- 2000
(Show Context)
Citation Context ...uctions we omit the type annotations on binders to save clutter, but that is mere abbreviation. An unusual feature of our system, which we share with Crary’s coercion calculus for inclusive subtyping =-=[11]-=-, is that values are stratified into cvalues and plain values; their syntax is in Figure 3. Evaluation reduces a closed term to a cvalue, or diverges. A cvalue is either a plain ¤ value (an abstractio... |

25 | A formulation of Dependent ML with explicit equality proofs
- Licata, Harper
- 2005
(Show Context)
Citation Context ...ntic notion of what σ1 ∼ σ2 “means”. We use the symbol 6 “∼” rather than “=”, to avoid suggesting that the two types are intensionally equal. Coercions are types – some would call them “constructors” =-=[25, 12]-=- since they certainly do not have kind ⋆ — and hence the term-level syntax for type abstraction and application (Λa.e and e ϕ) also serves for coercion abstraction and application. However, coercions ... |

22 | A framework for extended algebraic data types
- Sulzmann, Wazny, et al.
- 2006
(Show Context)
Citation Context ...ogonal extension that could easily be added. (Or, perhaps better, one could re-use types as kinds, but that is another story.) In a similar manner, the recently proposed extended algebraic data types =-=[34]-=-, which add equality and predicate constraints to GADTs, can be translated � � to . 2.5 Summary In this section we have shown that System F is inadequate as a typed intermediate language for source la... |

20 | P.J.: Understanding functional dependencies via constraint handling rules - Sulzmann, Duck, et al. - 2007 |

19 | Modular type classes
- DREYER, HARPER, et al.
- 2007
(Show Context)
Citation Context ...7]. Translucency and singleton kinds. In the work on ML-style module systems, type equalities are represented as singleton kinds, which are essential to model translucent signatures [14]. Recent work =-=[15]-=- demonstrated that such a module calculus can represent a wide range of type class programs including associated types. Hence, there is clearly an overlap with FC(X) equality axioms, which we use to r... |

15 |
The Role of Type Equality in Meta-Programming
- Pasalic
- 2004
(Show Context)
Citation Context ... & Régis-Gianas’s MLGI [29]. This is the approach that GHC initially took. � � is the result of a search for an alternative. Encoding GADTs in plain System F and F§ . There are several previous works =-=[3, 9, 26, 35, 7, 33]-=- which attempt an encoding of GADTs in plain System F with (boxed) existential types. We believe that these primitive encoding schemes are not practical and often non-trivial to achieve. We discuss th... |

13 | Type inference for GADTs via Herbrand constraint abduction
- Sulzmann, Schrijvers, et al.
- 2008
(Show Context)
Citation Context ...ng � constraint and type environment � , the source-language � expression has £ type , and translates to the � expression � � ”. The translation scheme can be made syntax� directed along the lines of =-=[27, 29, 32]-=-. The � constraint consists of a set of named type equalities: � � �¡ ¦¥¨§�©�� � � � � ��������� � � ��� � � The most interesting translation rules are shown in Figure 4, where we assume for simplicit... |

12 | Implementing cut elimination: A case study of simulating dependent types in Haskell
- Chen, Zhu, et al.
- 2004
(Show Context)
Citation Context ... & Régis-Gianas’s MLGI [29]. This is the approach that GHC initially took. � � is the result of a search for an alternative. Encoding GADTs in plain System F and F§ . There are several previous works =-=[3, 9, 26, 35, 7, 33]-=- which attempt an encoding of GADTs in plain System F with (boxed) existential types. We believe that these primitive encoding schemes are not practical and often non-trivial to achieve. We discuss th... |

11 |
Coercive subtyping for the calculus of constructions
- Chen
(Show Context)
Citation Context ... and theorem provers. The ideas from Mitchell’s work [25, 24] have also been transferred to dependently typed calculi as they are used in theorem provers; e.g., based on the Calculus of Constructions =-=[8]-=-. Generally, our coercion terms are a simple instance of the proof terms of logical frameworks, such as LF [16], or generally the evidence in intuitionistic type theory [22]. This connection indicates... |

7 |
Coercions in Hindley-Milner systems
- Luo, Kießling
- 2004
(Show Context)
Citation Context ...nguages. However, Mitchell’s coercion are not identities, but perform coercions between different numeric types and so forth. A more recent proposal of the same idea was presented by Kießling and Luo =-=[19]-=-. Subsequently, Mitchell [24] also studied coercions that are operationally identities to model type refinement for type inference in systems that go beyond Hindley/Milner. Much closer to � � is the w... |

7 |
A systematic translation of guarded recursive data types to existential types
- Sulzmann, Wang
- 2004
(Show Context)
Citation Context ... reversing the normalisation steps in Step 2. Failure in any of the steps implies � that £ ��� � � � � � CO does not hold for £ any . A constraint-based formulation of the above algorithm is given in =-=[33]-=-. To illustrate the algorithm, � � � �£��� � � � � � � � � ����� � let’s � consider � and � � � � � � � � � � � , with � � � � � . � � Step � � 1: �����©��� � ����������� � � � Normalising yields in a... |