## Concoqtion: Mixing dependent types and Hindley-Milner type inference (extended version (2006)

Citations: | 2 - 0 self |

### BibTeX

@TECHREPORT{Siek06concoqtion:mixing,

author = {Jeremy Siek and Walid Taha},

title = {Concoqtion: Mixing dependent types and Hindley-Milner type inference (extended version},

institution = {},

year = {2006}

}

### OpenURL

### Abstract

This paper addresses the question of how to extend OCaml’s Hindley-Milner type system with types indexed by logical propositions and proofs of the Coq theorem prover, thereby providing an expressive and extensible mechanism for ensuring fine-grained program invariants. We propose adopting the approached used by Shao et al. for certified binaries. This approach maintains a phase distinction between the computational and logical languages, thereby limiting effects and non-termination to the computational language, and maintaining the decidability of the type system. The extension subsumes language features such as impredicative first-class (higher-rank) polymorphism and type operators, that are notoriously difficult to integrate with the Hindley-Milner style of type inference that is used in OCaml. We make the observation that these features can be more easily integrated with type inference if the inference algorithm is free to adapt the order in which it solves typing constraints to each program. To this end we define a novel “order-free ” type inference algorithm. The key enabling technology is a graph representation of constraints and a constraint solver that performs Hindley-Milner inference with just three graph rewrite rules. 1

### Citations

985 | A Theory of Type Polymorphism in Programming
- Milner
- 1978
(Show Context)
Citation Context ...)τ We often use infix notation instead of prefix notation for types and drop parenthesis when the argument list is empty: int → int instead of → (int(), int()). We find Milner’s original presentation =-=[18]-=- of the Hindley-Milner type system (Figure 2) better suited to our purposes than the more commonly used Damas-Milner formulation [8]. There are several differences between Milner’s original formulatio... |

381 |
Principal type-schemes for functional programs
- Damas, Milner
- 1982
(Show Context)
Citation Context ...nstead of → (int(), int()). We find Milner’s original presentation [18] of the Hindley-Milner type system (Figure 2) better suited to our purposes than the more commonly used Damas-Milner formulation =-=[8]-=-. There are several differences between Milner’s original formulation and the Damas-Milner variant. Milner’s original is a predicate on typed terms, that is, terms with a type assigned to each subterm... |

347 | An efficient unification algorithm
- Martelli, Montanari
(Show Context)
Citation Context ... rules are graphically depicted in Figure 5. The first rewrite, unification, corresponds to the term reduction and variable elimination steps in Martelli and Montanari’s classic unification algorithm =-=[15]-=-. The unification rule relies on the following two definitions. Definition 2 (Vertex label compatibility). Two vertex labels a and b are compatible (written a ≈ b) iff a = b or a = ◦ or b = ◦. Definit... |

300 | Dependent types in practical programming
- Xi, Pfenning
- 1999
(Show Context)
Citation Context ...hes to introducing ideas from dependent type theory into traditional programming language design [2, 3, 16, 32] it is often an explicit goal of these approaches to automate the construction of proofs =-=[5, 13, 32, 39]-=-. In principle, automating the proofs can make programming easier. In reality, whether or not this is the case is a complex human-factors question. An alternative approach equally worthy of exploratio... |

224 | Cayenne - a language with dependent types
- Augustsson
- 1998
(Show Context)
Citation Context ...ner inference with just three graph rewrite rules. 1 Introduction While there have been several approaches to introducing ideas from dependent type theory into traditional programming language design =-=[2, 3, 16, 32]-=- it is often an explicit goal of these approaches to automate the construction of proofs [5, 13, 32, 39]. In principle, automating the proofs can make programming easier. In reality, whether or not th... |

171 | Local type inference
- Pierce, Turner
- 1998
(Show Context)
Citation Context ...aches, we use our order-free Hindley-Milner inference algorithm to propagate annotations. Most other approaches rely on bidirectional type inference (part of local inference) to propagate annotations =-=[27, 37, 39]-=-. We hypothesize that our approach propagates annotations to more locations and is easier to understand for functional programmers familiar with ML-style inference as they can continue to rely on thei... |

168 | Simple unification-based type inference for GADTs
- Jones, Vytiniotis, et al.
- 2006
(Show Context)
Citation Context ... The result of the branch has the length (1+(m2+n)) which is equal to the desired length ’(m+n). Let us compare the Concoqtion implementation of app to a similar implementation in Haskell using GADTs =-=[25]-=- (Figure 1b, following an example of Sheard’s [32]). The data-type ListN plays the same role as listN in Concoqtion, except that the integer values of the length index are encoded as Haskell types bui... |

137 | Guarded recursive datatype constructors
- Xi, Chen, et al.
- 2003
(Show Context)
Citation Context ...d to build it. This basic form of dependency can be used to encode a surprising variety of properties [4]. One of the first versions of GADTs was introduced by Xi (called guarded recursive data-types =-=[38]-=-). Integrating generalized algebraic data-types with ML-style type inference has been the focus of recent research (Pottier and Régis-Gianas [28], Stuckey and Sulzmann [33], and Vytiniotis, Weirich, a... |

130 |
Hybrid type checking
- Flanagan
- 2006
(Show Context)
Citation Context ...an simply make use of the numerous libraries, proofs and decision procedures for Coq. In future versions of Concoqtion, we also plan to integrate support for “proofs” by assertions and runtime checks =-=[10, 13, 23]-=- as a kind of “rapid prototyping” for proofs. 2.3 The Hindley-Milner Type Inference First an foremost, Concoqtion is backwards compatible with OCaml, so let-polymorphism continues to work as expected:... |

114 | Computation and reasoning. A type theory for computer science., volume 11 - Luo - 1994 |

111 | Phantom types
- Cheney, Hinze
- 2003
(Show Context)
Citation Context ...[33], and Vytiniotis, Weirich, and Peyton Jones [37]). Several languages with type systems directly supporting GADTs have been proposed, such 21 . . .sas First-Class Phantom Types of Cheney and Hinze =-=[6]-=-, extensions to the GHC Haskell compiler [37], and Ωmega of Sheard [32]. The advantages of GADTs are they are a natural extension of existing language features and type inference can be extended to in... |

101 | Putting type annotations to work
- Odersky, Läufer
- 1996
(Show Context)
Citation Context ...cularly challenging because the extension subsumes impredicative first-class polymorphism and type operators. Considerable research has gone into inference in the presence of first-class polymorphism =-=[11, 12, 19, 24, 30, 37]-=-, whereas much less research has gone into integrating type inference with type operators, with Pfenning’s partial inference as a notable exception [26]. What distinguishes our approach is its simplic... |

98 | Practical type inference for arbitrary-rank types
- Jones, Vytiniotis, et al.
(Show Context)
Citation Context ...cularly challenging because the extension subsumes impredicative first-class polymorphism and type operators. Considerable research has gone into inference in the presence of first-class polymorphism =-=[11, 12, 19, 24, 30, 37]-=-, whereas much less research has gone into integrating type inference with type operators, with Pfenning’s partial inference as a notable exception [26]. What distinguishes our approach is its simplic... |

97 |
Type inference with constrained types. Theory and Practice of Object Systems
- Odersky, Sulzmann, et al.
- 1999
(Show Context)
Citation Context ...nfer the type ∀a. a→ a for f, which then allows the inferencer to infer the type int→ int for the type application. Constraint-based inference algorithms, such as HM(X) of Odersky, Sulzmann, and Wehr =-=[20]-=-, provide a first step towards an order-free algorithm by separating inference into two parts: constraint generation and constraint solving. However, for the Hindley-Milner type system, it is non-triv... |

88 | Combining programming with theorem proving
- Chen, Xi
- 2005
(Show Context)
Citation Context ...hes to introducing ideas from dependent type theory into traditional programming language design [2, 3, 16, 32] it is often an explicit goal of these approaches to automate the construction of proofs =-=[5, 13, 32, 39]-=-. In principle, automating the proofs can make programming easier. In reality, whether or not this is the case is a complex human-factors question. An alternative approach equally worthy of exploratio... |

86 | A type system for certified binaries
- Shao, Trifonov, et al.
(Show Context)
Citation Context ...uire explaining many of their internal (and algorithmic) details. Our goal is to explore the language design approach that first proposed by Shao et al. in the context of intermediate language design =-=[31]-=-, and was later advocated in the context of source-language design by Pasalic, Taha and Sheard [23]. For the purposes of source language design, however, both these works assumed that the computationa... |

84 | Partial polymorphic type inference and higher-order unification
- Pfenning
- 1988
(Show Context)
Citation Context ...of first-class polymorphism [11, 12, 19, 24, 30, 37], whereas much less research has gone into integrating type inference with type operators, with Pfenning’s partial inference as a notable exception =-=[26]-=-. What distinguishes our approach is its simplicity, predictability, and indisputable expressive power. Instead of developing a new type system with incremental goals, we focus on developing a more ex... |

74 | Languages of the future
- Sheard
- 2004
(Show Context)
Citation Context ...ner inference with just three graph rewrite rules. 1 Introduction While there have been several approaches to introducing ideas from dependent type theory into traditional programming language design =-=[2, 3, 16, 32]-=- it is often an explicit goal of these approaches to automate the construction of proofs [5, 13, 32, 39]. In principle, automating the proofs can make programming easier. In reality, whether or not th... |

63 |
The essence of ML type inference
- Pottier, Rémy
- 2005
(Show Context)
Citation Context ...arts: constraint generation and constraint solving. However, for the Hindley-Milner type system, it is non-trivial to completely separate constraint generation and solving. Last year Pottier and Rémy =-=[29]-=- defined the first constraint-based Hindley-Milner inference algorithm with complete separation. The constraint solver of Pottier and Rémy, while mostly order free, still imposes some ordering restric... |

59 | Colored local type inference
- Odersky, Zenger, et al.
- 2001
(Show Context)
Citation Context ... are semi-decision procedures. In contrast, our algorithm does not guess universal types. Local type inference, as developed by Pierce and Turner [27] and later refined by Odersky, Zenger, and Zenger =-=[21]-=- is not conservative over ML programs, so it is not directly suitable for Concoqtion, which must remain backwards compatible with OCaml. Odersky and Läufer [19] define an extension of the Hindley-Miln... |

55 | Tagless staged interpreters for typed languages
- Pašalić, Taha, et al.
- 2002
(Show Context)
Citation Context ...ge design approach that first proposed by Shao et al. in the context of intermediate language design [31], and was later advocated in the context of source-language design by Pasalic, Taha and Sheard =-=[23]-=-. For the purposes of source language design, however, both these works assumed that the computational language being extended is explicitly typed, rather than being based on Hindley-Milner inference.... |

51 |
Epigram: Practical programming with dependent types
- McBride
- 2005
(Show Context)
Citation Context ...ner inference with just three graph rewrite rules. 1 Introduction While there have been several approaches to introducing ideas from dependent type theory into traditional programming language design =-=[2, 3, 16, 32]-=- it is often an explicit goal of these approaches to automate the construction of proofs [5, 13, 32, 39]. In principle, automating the proofs can make programming easier. In reality, whether or not th... |

40 | Stratified type inference for generalized algebraic data types
- Pottier, Régis-Gianas
- 2006
(Show Context)
Citation Context ... introduced by Xi (called guarded recursive data-types [38]). Integrating generalized algebraic data-types with ML-style type inference has been the focus of recent research (Pottier and Régis-Gianas =-=[28]-=-, Stuckey and Sulzmann [33], and Vytiniotis, Weirich, and Peyton Jones [37]). Several languages with type systems directly supporting GADTs have been proposed, such 21 . . .sas First-Class Phantom Typ... |

30 |
Indexed types
- Zenger
- 1997
(Show Context)
Citation Context ...rious logical properties expressed as Haskell data-types must be manipulated at runtime. 2.2 Using Decision Procedures Consider writing the function comm in DML [39] or Zenger’s indexed type language =-=[40]-=-. The cast would not be necessary and the equivalence m+n = n+m would be proved automatically by a Presburger arithmetic decision procedure that is built into the type checker. Clearly, this is less b... |

27 | A formulation of Dependent ML with explicit equality proofs
- Licata, Harper
- 2005
(Show Context)
Citation Context ...hes to introducing ideas from dependent type theory into traditional programming language design [2, 3, 16, 32] it is often an explicit goal of these approaches to automate the construction of proofs =-=[5, 13, 32, 39]-=-. In principle, automating the proofs can make programming easier. In reality, whether or not this is the case is a complex human-factors question. An alternative approach equally worthy of exploratio... |

26 |
partial type-inference for System F based on type-containment
- Simple
(Show Context)
Citation Context ...cularly challenging because the extension subsumes impredicative first-class polymorphism and type operators. Considerable research has gone into inference in the presence of first-class polymorphism =-=[11, 12, 19, 24, 30, 37]-=-, whereas much less research has gone into integrating type inference with type operators, with Pfenning’s partial inference as a notable exception [26]. What distinguishes our approach is its simplic... |

26 |
Endre Tarjan. Efficiency of a good but not linear set union algorithm
- Robert
- 1975
(Show Context)
Citation Context ...Our presentation immediately merges of nodes during unification, which is inefficient. The performance can be straightforwardly increased by using the standard union-find data-structure and algorithm =-=[34]-=-, which we do not show here as it would needlessly complicate the presentation. 3.2 Properties of Order-Free Inference In this section we present the properties of order-free Hindley-Milner type infer... |

25 |
Botlan and Didier Rémy. MLF: Raising ML to the power of System-F
- Le
- 2003
(Show Context)
Citation Context |

21 | Semi-explicit first-class polymorphism for ML
- Garrigue, Rémy
- 1999
(Show Context)
Citation Context |

16 | Type inference for guarded recursive data types
- Stuckey, Sulzmann
- 2005
(Show Context)
Citation Context ...uarded recursive data-types [38]). Integrating generalized algebraic data-types with ML-style type inference has been the focus of recent research (Pottier and Régis-Gianas [28], Stuckey and Sulzmann =-=[33]-=-, and Vytiniotis, Weirich, and Peyton Jones [37]). Several languages with type systems directly supporting GADTs have been proposed, such 21 . . .sas First-Class Phantom Types of Cheney and Hinze [6],... |

11 | Implementing typeful program transformations
- Chen, Xi
- 2003
(Show Context)
Citation Context ...ion of algebraic data-types so that the type of a data value may depend on what constructor is used to build it. This basic form of dependency can be used to encode a surprising variety of properties =-=[4]-=-. One of the first versions of GADTs was introduced by Xi (called guarded recursive data-types [38]). Integrating generalized algebraic data-types with ML-style type inference has been the focus of re... |

6 |
dependent types matter
- Why
- 2006
(Show Context)
Citation Context ...ed work Full spectrum dependent types Several lines of research involve enriching type systems by enabling types to depend on values. One approach involves the notion of full spectrum type dependency =-=[17]-=- in programming languages that are based on type theories [7, 14, for example]. In this approach, types may depend on arbitrary terms, thereby intermingling types and terms in a single language. Cayen... |

5 | The Quest Language and System
- Cardelli
- 1994
(Show Context)
Citation Context |

5 |
Boxy types: type inference for higher-rank types and impredicativity
- Vytiniotis, Weirich, et al.
- 2006
(Show Context)
Citation Context |

4 |
Type reconstruction in f[omega
- Urzyczyn
- 1997
(Show Context)
Citation Context ...algorithm. Specifying this type system requires care, because the naive combination of the Hindley-Milner rules with the Fω rules results in a type system for which there can be no complete algorithm =-=[36]-=-. The problem can be reduced to higher-order unification [26], which is also undecidable problem, and using a semi-decision procedure results in unpredictable behavior. To deal with this problem, and ... |

1 | and Gérard Huet. Concepts mathématiques et informatiques formalisés dans le calcul des constructions. Colloque de Logique - Coquand - 1985 |