## HMF: Simple type inference for first-class polymorphism (2008)

### Cached

### Download Links

Citations: | 17 - 1 self |

### BibTeX

@MISC{Leijen08hmf:simple,

author = {Daan Leijen},

title = {HMF: Simple type inference for first-class polymorphism},

year = {2008}

}

### OpenURL

### Abstract

HMF is a conservative extension of Hindley-Milner type inference with first-class polymorphism. In contrast to other proposals, HML uses regular System F types and has a simple type inference algorithm that is just a small extension of the usual Damas-Milner algorithm W. Given the relative simplicity and expressive power, we feel that HMF can be an attractive type system in practice. There is a reference implementation of the type system available online together with

### Citations

995 | A theory of type polymorphism in programming
- Milner
- 1978
(Show Context)
Citation Context ...d lambda calculus was first described by Curry and Feys [24]. Later, Hindley [2] introduced the notion of principal type, proving that the Curry and Feys algorithm inferred most general types. Milner =-=[3]-=- independently described a similar algorithm, but also introduced the important notion of first-order polymorphism where let-bound values can have a polymorphic type. Damas and Milner [4] later proved... |

994 |
A Machine-Oriented Logic Based on the Resolution Principle
- Robinson
- 1965
(Show Context)
Citation Context ...fore describing the actual type inference algorithm. 6.1 Unification Figure 5 describes a unification algorithm between polymorphic types. The algorithm is equivalent to standard Robinson unification =-=[22]-=- except that type variables can unify with polytypes and there is an extra case for unifying quantified types. The unification algorithm assumes that the types are in normal form. A type σ is in norma... |

384 |
Principal type-schemes for functional programs
- Damas, Milner
- 1982
(Show Context)
Citation Context ... can reuse common polymorphic abstractions over general polymorphic values. – There is a simple and effective type inference algorithm that infers principal types which is very similar to algorithm W =-=[4]-=-. In the following section we give an overview of HMF in practice. Section 4 presents the formal logical type rules of HMF followed by a description of the type inference algorithm in Section 6. Final... |

167 | Local type inference
- Pierce, Turner
- 1998
(Show Context)
Citation Context ...inference [5, 10]. 4.4 On the side conditions The Let rule restriction to most-general types is not new. It has been used for example in the typing of dynamics in ML [18], local type inference for F� =-=[19]-=-, semi-explicit first-class polymorphism [20], and more recently for boxy type in11sference [12]. All of these systems require some form of minimal solutions in order to have principal type derivation... |

113 |
The principal type scheme of an object in combinatory logic
- Hindley
- 1969
(Show Context)
Citation Context ...agile under small program transformations [6]. To the best of our knowledge, a type inference algorithm for the simply typed lambda calculus was first described by Curry and Feys [24]. Later, Hindley =-=[2]-=- introduced the notion of principal type, proving that the Curry and Feys algorithm inferred most general types. Milner [3] independently described a similar algorithm, but also introduced the importa... |

98 | Putting type annotations to work
- Odersky, Läufer
- 1996
(Show Context)
Citation Context ...restriction on let bindings. Finally, it is interesting that if we just restrict instantiation to monomorphic instantiation, we end up with a predicative type system for arbitrary rank type inference =-=[5, 10]-=-. 4.4 On the side conditions The Let rule restriction to most-general types is not new. It has been used for example in the typing of dynamics in ML [18], local type inference for F� [19], semi-explic... |

98 |
Type Assignment in Programming Languages
- Damas
- 1985
(Show Context)
Citation Context ...ymorphism where let-bound values can have a polymorphic type. Damas and Milner [4] later proved the completeness of Milner’s algorithm, extending the type inference system with polymorphic references =-=[25]-=-. Wells [1] shows that general type inference for unannotated System F is undecidable. Jones [7] extends Hindley-Milner with first class polymorphism by wrapping polymorphic values into type construct... |

96 | Practical Type Inference for Arbitrary-Rank Types
- Jones, Simon, et al.
- 2007
(Show Context)
Citation Context ...ive instantiation is not allowed). These are severe restrictions in practice. Even though uses of first-class polymorphism occur infrequently, there is usually no good alternative or work around (see =-=[5]-=- for a good overview). The reference calculus for first-class polymorphism is System F which is explicitly typed. As remarked by Rémy [6] one would like to have the expressiveness of System F combined... |

60 | Dynamics in ml
- Leroy, Mauny
- 1991
(Show Context)
Citation Context ...pe system for arbitrary rank type inference [5, 10]. 4.4 On the side conditions The Let rule restriction to most-general types is not new. It has been used for example in the typing of dynamics in ML =-=[18]-=-, local type inference for F� [19], semi-explicit first-class polymorphism [20], and more recently for boxy type in11sference [12]. All of these systems require some form of minimal solutions in order... |

50 | First-class polymorphism with type inference
- Jones
- 1997
(Show Context)
Citation Context ...he completeness of Milner’s algorithm, extending the type inference system with polymorphic references [25]. Wells [1] shows that general type inference for unannotated System F is undecidable. Jones =-=[7]-=- extends Hindley-Milner with first class polymorphism by wrapping polymorphic values into type constructors. This is a simple and effective technique that is widely used in Haskell but one needs to de... |

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

22 |
MLF: Une extension de ML avec polymorphisme de second ordre et instanciation implicite
- Botlan
- 2004
(Show Context)
Citation Context ... explicit type annotation must be given. 3 A comparision with MLF and boxy types In this section we compare HMF with two other type inference systems that support first-class polymorphism, namely MLF =-=[8, 9, 14, 15]-=- and boxy type inference [12]. MLF The MLF type system supports full first-class polymorphism, and only requires type annotations for parameters that are used polymorphically. As a consequence, MLF is... |

22 | Qualified types for MLF
- Leijen, Löh
- 2005
(Show Context)
Citation Context ...s that have to understand these types, but also for the meta theory of MLF, the implementation of the type inference algorithm, and the translation to System F (which is important for qualified types =-=[16, 17]-=-). HMF represents a different point in the design space where we want to use regular System F types only. As shown in Section 2.2, HMF does this at the price of also requiring annotations on ambigious... |

22 |
Combinatory Logic, volume 1
- Curry, Feys
- 1958
(Show Context)
Citation Context ... which can make it fragile under small program transformations [6]. To the best of our knowledge, a type inference algorithm for the simply typed lambda calculus was first described by Curry and Feys =-=[24]-=-. Later, Hindley [2] introduced the notion of principal type, proving that the Curry and Feys algorithm inferred most general types. Milner [3] independently described a similar algorithm, but also in... |

19 | Semi-explicit first-class polymorphism for ML
- Garrigue, Rémy
- 1999
(Show Context)
Citation Context ...o type constructors. This is a simple and effective technique that is widely used in Haskell but one needs to define a special constructor and operations for every polymorphic type. Garrigue and Rémy =-=[11]-=- use a similar technique but can use a generic ‘box’ operation to wrap polymorphic types. Odersky and Läufer [10] describe a type system that has higher-rank types but no impredicative instantiation. ... |

16 |
MLF: Raising ML to the power of System-F, in
- Botlan, Rémy
- 2003
(Show Context)
Citation Context ... explicit type annotation must be given. 3 A comparision with MLF and boxy types In this section we compare HMF with two other type inference systems that support first-class polymorphism, namely MLF =-=[8, 9, 14, 15]-=- and boxy type inference [12]. MLF The MLF type system supports full first-class polymorphism, and only requires type annotations for parameters that are used polymorphically. As a consequence, MLF is... |

15 | A graphical presentation of MLF types with a linear-time unification algorithm
- Rémy, Yakobowski
- 2007
(Show Context)
Citation Context ... explicit type annotation must be given. 3 A comparision with MLF and boxy types In this section we compare HMF with two other type inference systems that support first-class polymorphism, namely MLF =-=[8, 9, 14, 15]-=- and boxy type inference [12]. MLF The MLF type system supports full first-class polymorphism, and only requires type annotations for parameters that are used polymorphically. As a consequence, MLF is... |

12 |
Stepping through Haskell
- Dijkstra
- 2005
(Show Context)
Citation Context ...ypes. Odersky and Läufer [10] describe a type system that has higher-rank types but no impredicative instantiation. Peyton Jones et al. [5] extend this work with type annotation propagation. Dijkstra =-=[13]-=- extends this further with bidirectional annotation propagation to support impredicative instantiation. 8 Conclusion HMF is a conservative extention of Hindley-Milner type inference that supports firs... |

12 | Flexible types: robust type inference for first-class polymorphism
- Leijen
- 2008
(Show Context)
Citation Context ...and uses just System F types, but also requires annotations on ambiguous impredicative applications. Currently, we are working on a third system, called HML, that resides between these design points (=-=Leijen 2008-=-). This system is a simplification of MLF that only uses flexible types. The addition of flexible quantification leads to a very simple annotation rule where only function parameters with a polymorphi... |

12 | FPH: first-class polymorphism for Haskell - Vytiniotis, Weirich, et al. - 2008 |

11 | Botlan and Didier Rémy. Recasting MLF - Le - 2007 |

9 |
Lexically scoped type variables
- Jones, Shields
- 2004
(Show Context)
Citation Context ...s ∀αs. ST s α since the parameter itself is not polymorphic in α. For simplicity, we still require type annotations to be closed but of course it is possible to extend this with scoped type variables =-=[21]-=-, where annotations can contain free type variables that are bound elsewhere. We can formalize partial annotations in the type rules by modifying the annotation rule to assume fresh monotypes for the ... |

7 | Recasting MLF
- Botlan, Rémy
(Show Context)
Citation Context |

6 |
Boxy types: type inference for higher-rank types and impredicativity
- Vytiniotis, Weirich, et al.
- 2006
(Show Context)
Citation Context .... 3 A comparision with MLF and boxy types In this section we compare HMF with two other type inference systems that support first-class polymorphism, namely MLF [8, 9, 14, 15] and boxy type inference =-=[12]-=-. MLF The MLF type system supports full first-class polymorphism, and only requires type annotations for parameters that are used polymorphically. As a consequence, MLF is strictly more powerful than ... |

3 | Botlan and Didier Rémy. Recasting MLF. Research Report 6228 - Le - 2007 |

2 | partial type-inference for System-F based on type-containment - Simple - 2005 |

1 |
Typability and type checking in System-F are equivalent and undecidable
- Wells
- 1999
(Show Context)
Citation Context ...marked by Rémy [6] one would like to have the expressiveness of System F combined with the convenience of Hindley-Milner type inference. Unfortunately, full type inference for System F is undecidable =-=[1]-=-. Therefore, the only way to achieve our goal is to augment Hindley-Milner type inference with just enough programmer provided annotations to make programming with first-class polymorphism a joyful ex... |

1 | partial type-inference for System-F based on type-containment - Rémy - 2005 |

1 |
A type directed translation from MLF to System F
- Leijen
- 2007
(Show Context)
Citation Context ...s that have to understand these types, but also for the meta theory of MLF, the implementation of the type inference algorithm, and the translation to System F (which is important for qualified types =-=[16, 17]-=-). HMF represents a different point in the design space where we want to use regular System F types only. As shown in Section 2.2, HMF does this at the price of also requiring annotations on ambigious... |

1 |
Formal properties of the Hindley-Milner type system. Unpublished notes
- Jones
- 1995
(Show Context)
Citation Context ...infer(Γ, e) = (θ, σ) then θΓ ⊢ e : σ holds. Theorem 8 (Type inference is complete and principal): If θΓ ⊢ e : σ, then infer(Γ, e) = (θ ′ , σ ′ ) where θ ≈ θ ′′ ◦ θ ′ and θ ′′ σ ′ ⊑ σ. Following Jones =-=[23]-=-, we use the notation S1 ≈ S2 to indicate that S1α = S2α for all but a finite number of fresh type variables. In most cases, we can treat S1 ≈ S2 as S1 = S2 since the only differences between substitu... |

1 | 2007a. Daan Leijen. HMF: Simple type inference for first-class polymorphism - html |

1 | Lexically scoped type Simon Peyton Jones, Dimitrios Vytiniotis, Stephanie - Draft - 2004 |