## Polymorphic Subtyping in O'Haskell (2001)

Venue: | APPSEM Workshop on Subtyping and Dependent Types in Programming, 2000 |

Citations: | 4 - 0 self |

### BibTeX

@INPROCEEDINGS{Nordlander01polymorphicsubtyping,

author = {Johan Nordlander},

title = {Polymorphic Subtyping in O'Haskell},

booktitle = {APPSEM Workshop on Subtyping and Dependent Types in Programming, 2000},

year = {2001}

}

### OpenURL

### Abstract

O'Haskell is a programming language derived from Haskell by the addition of concurrent reactive objects and subtyping. Because Haskell already encompasses an advanced type system with polymorphism and overloading, the type system of O'Haskell is much richer than what is the norm in almost any widespread object-oriented or functional language. Yet there is strong evidence that O'Haskell is not a complex language to use, and that both Java and Haskell programmers can easily find their way with its polymorphic subtyping system. This paper describes the type system of O'Haskell both formally and from a programmer's point of view; the latter task is accomplished with the aid of an illustrative, real world programming example: a strongly typed interface to the graphical toolkit Tk.

### Citations

1619 | The definition of Standard ML - Milner, Tofte, et al. - 1997 |

1264 | Tcl and the Tk Toolkit
- Ousterhout
- 1994
(Show Context)
Citation Context ... of the merits of the polymorphic subtyping system of O’Haskell, we will use a real, implemented program library as our main example: a statically typed interface to Ousterhout’s graphical toolkit=-= Tk [Ous94]. Th-=-e Tk interface is part of the distribution of the O’Haskell interpreter O’Hugs, which can be downloaded freely from http:/www.cs.chalmers.se/~nordland/ohugs/ It is our intention that this concrete... |

978 | A theory of type polymorphism in programming
- Milner
- 1978
(Show Context)
Citation Context ... ≤ CPoint} and {α ≤ β, Point ≤ β}, solving the first set separately would lead to success even with our simple strategy. This requirement actually puts us closer to the standard inference alg=-=orithm W [Mil78]-=- than is customary in the literature on subtype inference. As we have indicated, we will have good reasons for solving constraints as soon as they are generated, rather than propagating them upwards i... |

924 | A theory of objects
- Abadi, Cardelli
- 1996
(Show Context)
Citation Context ...sent in their system, in favor of records that may carry types as well as terms as components. Subtyping based on variance annotations can be found in the various object calculi by Abadi and Cardelli =-=[AC96], -=-although here the annotations are attached to method names instead of type constructor arguments. Freeman’s work on refinement types involves inferred variances for datatype constructor arguments [F... |

788 | On understanding types, data abstraction and polymorphism
- Cardelli, Wegner
- 1985
(Show Context)
Citation Context ...tion behind these rules is of course the standard rule for depth subtyping at the function type, which says that S -> T is a subtype of S’ -> T’ only if S’ is a subtype of S, and T is a subtype =-=of T’ [CW85]. -=-O’Haskell naturally supports this rule, as well as covariant subtyping for the built-in container types lists, tuples, and arrays. Depth subtyping may now be transitively combined with subtype axiom... |

346 | An Efficient Unification Algorithm
- Martelli, Montanari
- 1982
(Show Context)
Citation Context ...imating subtype constraint solver, which has the merit of being simple and efficient — in fact it is defined as a small extension to the very efficient unification algorithm of Martelli and Montanar=-=i [MM82]. Th-=-e main characteristic of our solver is that it approximates constraints of the form α ≤ β as equality constraints, and resorts to unification in these cases. When all such constraints are removed ... |

326 | Pizza into Java: Translating Theory into Practice
- Odersky, Wadler
- 1997
(Show Context)
Citation Context ...tructors with declared non-atomic upper bounds, but the type constructors themselves must always have zero arity [Seq98]. The language closest to O’Haskell in this respect is the Java extension Pizz=-=a [OW97]-=-, which allows classes to be parameterized on types, and which supports extension of parameterized classes in a way that resembles our polymorphic subtype axioms. There is also a notion of algebraic d... |

223 | Type inclusion constraints and type inference
- Aiken, Wimmers
- 1993
(Show Context)
Citation Context ...e rather designed to have a negligible effect in this respect. Aiken and Wimmers’ constraint solver also makes some non-conservative, but hardly radical, simplifications in the interest of efficienc=-=y [AW93]-=-. Reppy and Riecke, though, have implemented type inference for their object-oriented ML variant OML, in such a way that only constraint-free type schemes are inferred [RR96]. However, they do not des... |

182 | Refinement types for ML
- Freeman, Pfenning
- 1991
(Show Context)
Citation Context ...6], although here the annotations are attached to method names instead of type constructor arguments. Freeman’s work on refinement types involves inferred variances for datatype constructor argument=-=s [Fre94], -=-but his setting is rather different from ours, in the sense that his subtyping system serves to provide additional information on terms that already have an ML type. The system ML≤ allows both varia... |

170 | Local type inference
- Pierce, Turner
(Show Context)
Citation Context ...ndeed, when the limitations of local type inference are discussed, it is noticeable that the provided examples are exclusively chosen among the category of programs that would be typeable in plain ML =-=[HP99]-=-. Having a declarative specification obviously does not help much if the programmer intuitively is using a different kind of system. We believe our algorithm works because it is complete w.r.t. both t... |

105 | Sound polymorphic type inference for objects - Eifrig, Smith, et al. - 1995 |

98 | Type inference with simple subtypes - Mitchell - 1991 |

78 | Type inference with subtypes - Fuh, Mishra - 1988 |

73 | Simplifying subtyping constraints - Pottier - 1996 |

72 | Coercion and type inference - Mitchell - 1984 |

65 | Using parameterized signatures to express modular structure - Jones - 1996 |

63 | Polymorphic type inference and abstract data types - Läufer, Odersky - 1994 |

62 | Subtyping constrained types
- Trifonov, Smith
- 1996
(Show Context)
Citation Context ... EST95, Reh97, MW97, Pot98, Pot00] in particular. The choice to settle for a deliberately incomplete inference algorithm sets our work apart from most of the cited systems, though. Smith and Trifonov =-=[TS96]-=-, and Pottier [Pot96, Pot98] approximate entailment checking with decidable variants that result in loss of information, but this move is not motivated by any desire to actually eliminate constrained ... |

59 | Colored local type inference
- Odersky, Zenger, et al.
- 2001
(Show Context)
Citation Context ... and checking, which ours does not. A recent proposal for colored local type inference, that allows propagation of partial type information in a top-down manner, is closer to our work in this respect =-=[OZZ01]. Cardel-=-li’s implementation of F≤ [Car93] contains a partial type inference algorithm that, like ours, uses unification to solve constraints involving unbound type variables. However, this “greedy” al... |

55 | Type inference in the presence of overloading, subtyping and recursive types - Kaes - 1992 |

53 | A practical subtyping system for Erlang - Marlow, Wadler - 1997 |

51 | Type-checking higher-order polymorphic multi-methods
- Bourdoncle, Merz
- 1997
(Show Context)
Citation Context ...L type. The system ML≤ allows both variances and subtype orderings to be declared, but imposes the restriction that the variance as well as the arity must be uniform for all related type constructor=-=s [BM97]-=-. We are not aware of any system besides ours that provides a combination of subtype 30sdeclarations as general as our polymorphic subtype axioms, and variance-based depth subtyping. Objective Caml (O... |

49 | First-class Polymorphism with Type Inference - Jones - 1997 |

48 | Type inference with constrained types - Sulzmann, Odersky, et al. - 1997 |

45 | Principal type schemes for functional programs with overloading and subtyping - Smith - 1994 |

44 | Simple objects for Standard ML
- Reppy, Riecke
- 1996
(Show Context)
Citation Context ...he interest of efficiency [AW93]. Reppy and Riecke, though, have implemented type inference for their object-oriented ML variant OML, in such a way that only constraint-free type schemes are inferred =-=[RR96]. -=-However, they do not describe their algorithm, nor do they provide any technical results. Most related to our approach is Pierce and Turner’s work on local type inference for Pict [PT98]. They start... |

39 | Simplifying subtyping constraints: a theory - Pottier - 2001 |

32 | Polymorphic subtype inference: Closing the theorypractice gap - Fuh, Mishra - 1989 |

28 |
Reactive Objects and Functional Programming
- Nordlander
- 1999
(Show Context)
Citation Context ...en in general in [Hen96], and which continue to hold for our basic system in particular. Furthermore, our record and datatype extension only trivially affects most of the original proofs. We refer to =-=[Nor99] for all proof details. Le-=-mma 6.3. If C, Γ ⊢P e : σ then ΦC, ΦΓ ⊢P e : Φσ for all substitutions Φ. Lemma 6.4. If C, Γ ⊢P e : σ and D ⊢P C then D, Γ ⊢P e : σ. Proposition 6.5. Let α /∈ fv(C, Γ). Then C... |

26 | Structuring Graphical Paradigm in TkGofer
- Claessen, Vullinghs, et al.
- 1997
(Show Context)
Citation Context ...purely functional layout operators. We believe that this clarity and explicit structure represents an immediate advantage over other strongly typed Tk interfaces, notably the one presented by TkGofer =-=[CMV97]-=-. 5 A Tk client example As an example of how the Tk interface is intended to be used, we give an example of a typical graphics intensive, interactive Tk client in this section. Our client example is a... |

23 | A franiework for type inference with subtyping - Pottier - 1998 |

21 | Lightweight extensible records for Haskell - Jones, Jones - 1999 |

19 | Making set-constraint program analyses scale, Workshop on Set Constraints - Fahndrich, Aiken - 1996 |

17 | An implementation of F
- Cardelli
- 1993
(Show Context)
Citation Context ...ent proposal for colored local type inference, that allows propagation of partial type information in a top-down manner, is closer to our work in this respect [OZZ01]. Cardelli’s implementation of F=-=≤ [Car93] con-=-tains a partial type inference algorithm that, like ours, uses unification to solve constraints involving unbound type variables. However, this “greedy” algorithm solves all constraints, including... |

14 | Minimal typings in atomic subtyping - Rehof - 1997 |

13 |
Type inference with extended pattern matching and subtypes
- Jategaonkar, Mitchell
- 1993
(Show Context)
Citation Context ...much attention. Reppy and Riecke’s OML employs a scheme where object types are related by declaration [RR96], while Jategonkar and Mitchell outline a similar (future) system for abstract datatypes i=-=n [JM93]-=-. Both these systems consider only parameterless type constants. Sequeira allows user-defined type constructors with declared non-atomic upper bounds, but the type constructors themselves must always ... |

13 | Pragmatic subtyping in polymorphic languages
- Nordlander
(Show Context)
Citation Context ...of all programs that the inference algorithm accepts. Their method for inferring types for anonymous abstractions is moreover similar to our implementation of integrated type-checking (as reported in =-=[Nor98]-=-), although their algorithm switches between strict phases of inference and checking, which ours does not. A recent proposal for colored local type inference, that allows propagation of partial type i... |

11 | the Hopkins Objects Group (Jonathan Eifrig - Bruce, Cardelli, et al. - 1996 |

11 | Simple Usage Polymorphism
- Wansbrough, Jones
- 2000
(Show Context)
Citation Context ...or can sometimes appear quite unpredictable. In the specific setting of usage analysis, Wansbrough and Peyton Jones describe a constraint approximating algorithm that has similarities to our approach =-=[WP00]-=-. They share our objective to infer constraint-free types only, they resort to unification for variable-to-variable constraints, and they also notice the problems inherent in finding a precise specifi... |

10 | Reactive objects in a functional language – an escape from the evil - Nordlander, Carlsson - 1997 |

10 |
Rémy and Jérôme Vouillon. Objective ML: A simple object-oriented extension of ML
- Didier
- 1997
(Show Context)
Citation Context ... Objective Caml (Objective ML) conservatively extends ML with subtype inference and a powerful type abbreviation mechanism that achieves much of the succinctness we obtain by using name inequivalence =-=[RV97]-=-. However, the type system of Objective Caml is based on extensible records (in contrast to extensible record types), and does not support subsumption. Many of the systems mentioned allow subtype cons... |

8 | Nested types
- Odersky, Zenger
- 2001
(Show Context)
Citation Context ... remains as future work. Recent work by Odersky and Zenger introduces the term nominal to denote type systems where equality and subtyping is based on declaration rather than on structural properties =-=[OZ01]-=-. The authors argue that such systems are more suitable than the usual theoretical approaches for modelling common objectoriented languages, a position we have taken in our work as well. Odersky and Z... |

8 | Polymorphic extensible records for Haskell - Gaster - 1997 |

5 | Syntactic properties of polymorphic subtyping
- Henglein
- 1996
(Show Context)
Citation Context ...s in our calculus. With the possible exception of rules Depth and Const, this system is standard in the subtyping literature; in particular, it directly corresponds to a system studied by Henglein in =-=[Hen96]. Ru-=-le Depth depends on the given variance of a type constant, as captured by the following notation: For every type constant t, let the sets t + , t − ⊆ {1 . . . nt} represent the argument indices th... |

4 |
Type Inference with Bounded Quantification
- Sequeira
- 1998
(Show Context)
Citation Context ...tems consider only parameterless type constants. Sequeira allows user-defined type constructors with declared non-atomic upper bounds, but the type constructors themselves must always have zero arity =-=[Seq98]. -=-The language closest to O’Haskell in this respect is the Java extension Pizza [OW97], which allows classes to be parameterized on types, and which supports extension of parameterized classes in a wa... |

3 |
The Haskell Home
- Peterson
- 1997
(Show Context)
Citation Context ...O’Haskell is the result of a finely tuned combination of ideas and concepts from functional, object-oriented, and concurrent programming, that has its origin in the purely functional language Haskel=-=l [Pet97]. -=-The name O’Haskell is a tribute to this parentage, where the O should be read as an indication of Objects, as well as a reactive breach with the tradition that views Input as an active operation on ... |

1 |
Fudgets – A Graphical User Interface in a Functional Language
- Carlsson, Hallgren
- 1993
(Show Context)
Citation Context ...e packing algorithm is instead initiated by invoking the pack method of some top-level window. The convenient use of combinators to express layout is an idea borrowed from the Fudget graphics library =-=[CH93]-=-. 4.2 Configuration options The various configuration options are defined as constructors in a hierarchy of datatypes. Because the widget types are parametric in their option type, this option hierarc... |

1 |
Polymorphic type inference
- Leviant
- 1983
(Show Context)
Citation Context ...r Right b instead of Left a. So, for some fixed a, a value of type Left a can also be considered to be of type Either a b, for all b. This typing flexibility is actually a form of rank-2 polymorphism =-=[Lev83]-=-, which is put to good use in the following example. f v@(Left _) = v f (Right 0) = Right False f (Right _) = Right True The interesting part here is the first defining equation. Thanks to subtyping, ... |