## A constraint-based approach to guarded algebraic data types (2007)

### Cached

### Download Links

- [gallium.inria.fr]
- [cristal.inria.fr]
- [www.normalesup.org]
- [www.normalesup.org]
- DBLP

### Other Repositories/Bibliography

Venue: | ACM Trans. Prog. Languages Systems |

Citations: | 24 - 0 self |

### BibTeX

@ARTICLE{Simonet07aconstraint-based,

author = {Vincent Simonet and François Pottier},

title = {A constraint-based approach to guarded algebraic data types},

journal = {ACM Trans. Prog. Languages Systems},

year = {2007}

}

### OpenURL

### Abstract

We study HMG(X), an extension of the constraint-based type system HM(X) with deep pattern matching, polymorphic recursion, and guarded algebraic data types. Guarded algebraic data types subsume the concepts known in the literature as indexed types, guarded recursive datatype constructors, (first-class) phantom types, and equality qualified types, and are closely related to inductive types. Their characteristic property is to allow every branch of a case construct to be typechecked under different assumptions about the type variables in scope. We prove that HMG(X) is sound and that, provided recursive definitions carry a type annotation, type inference can be reduced to constraint solving. Constraint solving is decidable, at least for some instances of X, but prohibitively expensive. Effective type inference for guarded algebraic data types is left as an issue for future research.

### Citations

939 | A theory of type polymorphism in programming - Milner - 1978 |

540 | A syntactic approach to type soundness - Wright, Felleisen - 1994 |

537 | S.: The Implementation of Functional Programming Languages - Jones - 1987 |

346 | How to make ad-hoc polymorphism less ad hoc
- Wadler, Blott
- 1989
(Show Context)
Citation Context ...ints are standard unification constraints. Second, working with constraints allows moving to much more general settings, where constraints may involve type class membership predicates, as in Haskell [=-=Wadler and Blott 1989-=-; Jones 1994], Presburger arithmetic, as in DML [Xi 1998], polynomials, as in Zenger’s work [1997], subtyping, etc. Of course, in each case, one must write a different constraint solver, which can be ... |

289 | Dependent types in practical programming
- Xi, Pfenning
- 1999
(Show Context)
Citation Context ...hat only lists of length k have type list(τ, k). Type systems that allow dealing with lists in this manner include Zenger’s indexed types [1997; 1998] and Xi and Pfenning’s so-called dependent types [=-=Xi 1998-=-; Xi and Pfenning 1999]. Both are constraint-based type systems, where typechecking relies on the decidability of constraint entailment, as opposed to true dependent type systems, where typechecking i... |

217 | Type inclusion constraints and type inference
- Aiken, Wimmers
- 1993
(Show Context)
Citation Context ...] as the foundation for our work, because of its elegance, it is by no means the only constraint-based type system in existence. Many others have been defined and studied [Mitchell 1984; Curtis 1990; =-=Aiken and Wimmers 1993-=-; Jones 1994; Smith 1994; Trifonov and Smith 1996; Pottier and Rémy 2005], of which it would be difficult to give a comprehensive list. One could in principle add guarded algebraic data types to any o... |

173 | Refinement Types for ML
- Freeman, Pfenning
- 1991
(Show Context)
Citation Context ...ystem means accepting more programs. On the other hand, it also allows writing more precise type specifications, thus rejecting some (safe, but incorrect) programs, in the spirit of refinement types [=-=Freeman and Pfenning 1991-=-]. ACM Transactions on Programming Languages and Systems, Vol. TBD, No. TDB, Month Year.Constraint-Based Type Inference for Guarded Algebraic Data Types · 9 One point should perhaps be stressed. Guar... |

165 | Local Type Inference
- Pierce, Turner
- 1998
(Show Context)
Citation Context ...while the environment fragment ⦇p ↑ τ⦈ represents knowledge about the bindings that arise when such a test succeeds. (Note that our use of ↓ and ↑ has nothing to do with bidirectional type inference [=-=Pierce and Turner 2000-=-].) The first three rules of each group directly reflect p-Empty, p-Wild, and p-Var. The fourth rules of the first and second groups directly reflect p-And. The former states that it is legal to match... |

163 | Inductive Definitions in the System Coq: Rules and Properties
- Paulin-Mohring
- 1993
(Show Context)
Citation Context ...t the details. Appearances of this concept in the literature. Declarations of the form (4) are strongly reminiscent of the way inductive types are declared in the Calculus of Inductive Constructions [=-=Paulin-Mohring 1992-=-; Werner 1994]. The main difference lies in the fact that inductive types come with a positivity restriction, which ensures logical consistency, whereas guarded algebraic data types carry no such rest... |

155 | Simple unificationbased type inference for GADTs - Jones, Vytiniotis, et al. - 2006 |

144 | The Principal Type-Scheme of an Object in Combinatory Logic - Hindley - 1969 |

142 | Intensional polymorphism in type-erasure semantics
- Crary, Weirich, et al.
- 1998
(Show Context)
Citation Context ...y. In a practical application, it could have more. The motivation for this definition is the following: ty(τ) can be interpreted as a singleton type whose only value is a runtime representation of τ [=-=Crary et al. 2002-=-]. The constraints carried by the above declarations capture the relationship between the structure of a value v whose type is ty(τ) and that of the type τ. Indeed, if v is Int, then τ must be int; if... |

137 |
Complete Axiomatizations of the Algebras of Finite, Rational and Infinite Trees
- Maher
- 1988
(Show Context)
Citation Context ...edicates other than equality are available, and assuming that types receive their standard interpretation as elements of a free algebra of (finite or infinite) terms, constraint solving is decidable [=-=Maher 1988-=-; Comon and Lescanne 1989]. More generally, assuming that no basic predicates other than subtyping are available, and assuming that subtyping receives a structural interpretation, constraint solving r... |

132 |
Qualified Types: Theory and Practice
- Jones
- 1994
(Show Context)
Citation Context ...our work, because of its elegance, it is by no means the only constraint-based type system in existence. Many others have been defined and studied [Mitchell 1984; Curtis 1990; Aiken and Wimmers 1993; =-=Jones 1994-=-; Smith 1994; Trifonov and Smith 1996; Pottier and Rémy 2005], of which it would be difficult to give a comprehensive list. One could in principle add guarded algebraic data types to any of them. The ... |

131 | Guarded recursive datatype constructors - Xi, Chen, et al. - 2003 |

124 | 98. Language and Libraries. The Revised Report - Haskell - 2003 |

104 | Equational problems and disunification
- Comon, Lescanne
- 1989
(Show Context)
Citation Context ...er than equality are available, and assuming that types receive their standard interpretation as elements of a free algebra of (finite or infinite) terms, constraint solving is decidable [Maher 1988; =-=Comon and Lescanne 1989-=-]. More generally, assuming that no basic predicates other than subtyping are available, and assuming that subtyping receives a structural interpretation, constraint solving remains decidable [Kuncak ... |

103 | First-class phantom types - Cheney, Hinze - 2003 |

95 | Putting type annotations to work - Odersky, Laufer - 1996 |

91 |
Type inference with constrained types. Theory and Practice of Object Systems
- Odersky, Sulzmann, et al.
- 1999
(Show Context)
Citation Context ... and constraint solving phases, where constraints are, roughly speaking, systems of type equations. This remark has led to the definition of a family of constraint-based type systems, known as HM(X) [=-=Odersky et al. 1999-=-; Pottier and Rémy 2005], whose members exploit potentially more complex constraint languages, achieving greater expressiveness while still enjoying type inference in the style of Hindley and Milner. ... |

88 | Higher-order extensions to Prolog: are they needed - Warren - 1982 |

79 | Nested datatypes
- BIRD, MEERTENS
- 1998
(Show Context)
Citation Context ...ssigned to K, which can be derived from the declaration of ε, is of the form K :: ∀¯α.τ1 × · · · × τn → ε(¯α) (1) where n is the arity of K. (This form includes so-called nested algebraic data types [=-=Bird and Meertens 1998-=-].) Then, the typing discipline for pattern matching can be summed up as follows: if the pattern K x1 · · · xn matches a value of type ε(¯α), then the variable xi becomes bound to a value of type τi. ... |

74 | A lightweight implementation of generics and dynamics - Cheney, Hinze - 2002 |

71 |
Coercion and type inference
- Mitchell
- 1984
(Show Context)
Citation Context ...e HM(X) [Odersky et al. 1999] as the foundation for our work, because of its elegance, it is by no means the only constraint-based type system in existence. Many others have been defined and studied [=-=Mitchell 1984-=-; Curtis 1990; Aiken and Wimmers 1993; Jones 1994; Smith 1994; Trifonov and Smith 1996; Pottier and Rémy 2005], of which it would be difficult to give a comprehensive list. One could in principle add ... |

69 | Languages of the future - Sheard - 2004 |

62 | Polymorphic type inference and abstract data types
- Läufer, Odersky
- 1994
(Show Context)
Citation Context ...quiring the type variables ¯ β to be fresh, the third premise ensures that they remain abstract within e; this condition is identical to that found in the elimination construct for existential types [=-=Läufer and Odersky 1994-=-]. A key point, here, is the fact that e is typechecked under the augmented constraint C ∧ D. In other words, the type system exploits the presence of a dynamic check, namely pattern matching, to obta... |

60 | Subtyping constrained types
- Trifonov, Smith
- 1996
(Show Context)
Citation Context ... elegance, it is by no means the only constraint-based type system in existence. Many others have been defined and studied [Mitchell 1984; Curtis 1990; Aiken and Wimmers 1993; Jones 1994; Smith 1994; =-=Trifonov and Smith 1996-=-; Pottier and Rémy 2005], of which it would be difficult to give a comprehensive list. One could in principle add guarded algebraic data types to any of them. The usefulness of guarded algebraic data ... |

57 |
Une Théorie des Constructions Inductives
- Werner
- 1994
(Show Context)
Citation Context ...ances of this concept in the literature. Declarations of the form (4) are strongly reminiscent of the way inductive types are declared in the Calculus of Inductive Constructions [Paulin-Mohring 1992; =-=Werner 1994-=-]. The main difference lies in the fact that inductive types come with a positivity restriction, which ensures logical consistency, whereas guarded algebraic data types carry no such restriction. In a... |

56 |
The essence of ML type inference
- Pottier, Rémy
(Show Context)
Citation Context ...ng phases, where constraints are, roughly speaking, systems of type equations. This remark has led to the definition of a family of constraint-based type systems, known as HM(X) [Odersky et al. 1999; =-=Pottier and Rémy 2005-=-], whose members exploit potentially more complex constraint languages, achieving greater expressiveness while still enjoying type inference in the style of Hindley and Milner. These programming langu... |

55 | Programming Objects with ML-ART: An Extension to ML with Abstract and Record Types - Rémy - 1994 |

54 | Run-time principals in information-flow type systems - Tse, Zdancewic - 2004 |

49 |
The Objective Caml System
- Leroy
(Show Context)
Citation Context ...2 · V. Simonet and F. Pottier can be brought together. In order to introduce guarded algebraic data types into mainstream programming languages such as Haskell [Peyton Jones 2003] or Objective Caml [=-=Leroy et al. 2005-=-], it is necessary to study their interaction with Hindley-Milner-style type inference. Furthermore, because type inference is best understood in a constraint-based setting, and because constraint-bas... |

48 | Wobbly types: type inference for generalised algebraic data types - Jones, Washburn, et al. - 2004 |

44 | Principal type schemes for functional programs with overloading and subtyping
- Smith
- 1994
(Show Context)
Citation Context ...cause of its elegance, it is by no means the only constraint-based type system in existence. Many others have been defined and studied [Mitchell 1984; Curtis 1990; Aiken and Wimmers 1993; Jones 1994; =-=Smith 1994-=-; Trifonov and Smith 1996; Pottier and Rémy 2005], of which it would be difficult to give a comprehensive list. One could in principle add guarded algebraic data types to any of them. The usefulness o... |

37 | Stratified type inference for generalized algebraic data types - Pottier, Régis-Gianas |

33 | Fun with phantom types - Hinze - 2003 |

31 | Type-safe cast: (functional pearl - Weirich - 2000 |

30 | A General Framework for Hindley/Milner Type Systems with Constraints - Sulzmann - 2000 |

29 | Indexed types - Zenger - 1997 |

28 | An Improved Lower Bound for the Elementary Theories of Trees
- Vorobyov
- 1996
(Show Context)
Citation Context ...nd Rinard 2003]. Unfortunately, these decidability results are only of theoretical interest, because the complexity of constraint solving for the first-order theory of term equality is nonelementary [=-=Vorobyov 1996-=-]. In other words, even in the simplest case above, where no basic predicates other than equality are available, the constraints that we produce belong to a class whose satisfiability problem is intra... |

25 | M.: Structural subtyping of non-recursive types is decidable
- Kuncak, Rinard
- 2003
(Show Context)
Citation Context ...ne 1989]. More generally, assuming that no basic predicates other than subtyping are available, and assuming that subtyping receives a structural interpretation, constraint solving remains decidable [=-=Kuncak and Rinard 2003-=-]. Unfortunately, these decidability results are only of theoretical interest, because the complexity of constraint solving for the first-order theory of term equality is nonelementary [Vorobyov 1996]... |

25 | Dead code elimination through dependent types - Xi - 1999 |

23 |
Constrained quantification in polymorphic type analysis
- Curtis
- 1990
(Show Context)
Citation Context ...y et al. 1999] as the foundation for our work, because of its elegance, it is by no means the only constraint-based type system in existence. Many others have been defined and studied [Mitchell 1984; =-=Curtis 1990-=-; Aiken and Wimmers 1993; Jones 1994; Smith 1994; Trifonov and Smith 1996; Pottier and Rémy 2005], of which it would be difficult to give a comprehensive list. One could in principle add guarded algeb... |

23 | Constraint-based type inference for guarded algebraic data types
- Simonet, Pottier
- 2005
(Show Context)
Citation Context ...nts between static level variables—just as, in §1.2, examining runtime type representations allowed recovering equations between static type variables. Some more details appear in a technical report [=-=Simonet and Pottier 2005-=-, Section 2.3]. A similar approach is followed by Tse and Zdancewic [2004], who introduce dynamic principals into an information flow analysis. 1.5 Related work 1.5.1 Related type systems. Although we... |

18 | Meta-programming With Built-in Type Equality - Sheard, Pasalic - 2008 |

17 | Polymorphic typed defunctionalization - Pottier, Gauthier - 2004 |

16 | Hindley/Milner style type systems in constraint form - Sulzmann, Müller, et al. - 1999 |

15 | Type inference for guarded recursive data types - Stuckey, Sulzmann - 2005 |

15 | Dependently Typed Pattern Matching - Xi |

15 | Applied type system - Xi - 2004 |