## Uniqueness Typing Simplified

Citations: | 5 - 1 self |

### BibTeX

@MISC{Vries_uniquenesstyping,

author = {Edsko De Vries and Rinus Plasmeijer and David M Abrahamson},

title = {Uniqueness Typing Simplified},

year = {}

}

### OpenURL

### Abstract

Abstract. We present a uniqueness type system that is simpler than both Clean’s uniqueness system and a system we proposed previously. The new type system is straightforward to implement and add to existing compilers, and can easily be extended with advanced features such as higher rank types and impredicativity. We describe our implementation in Morrow, an experimental functional language with both these features. Finally, we prove soundness of the core type system with respect to the call-by-need lambda calculus. 1 Introduction to Uniqueness Typing An important property of pure functional programming languages is referential transparency: the same expression used twice must have the same value twice. This makes equational reasoning possible and aids program analysis, but most languages do not have this property. For example, in the following C fragment,

### Citations

965 |
Term rewriting and all that
- Baader, Nipkow
- 1998
(Show Context)
Citation Context ...s is most general, and it is not obvious that the equation u∨v ≃ • even has a most general unifier, which means we would lose principal types. Fortunately, unification in a boolean algebra is unitary =-=[9]-=-. In other words, if a boolean equation has a solution, it has a most general solution. In the example, one most general solution is [u ↦→ u, v ↦→ v ∨ ¬u].unify0 :: BooleanAlgebra a => a -> [Var] -> ... |

373 |
Principal type-schemes for functional programs
- Damas, Milner
- 1982
(Show Context)
Citation Context ...ion, and non-unique functions can be used multiple times. 5 Boolean Unification One advantage of removing constraints from the type language is that standard inference algorithms (such as algorithm W =-=[8]-=-) can be applied without any modifications. The inference algorithm will depend on a unification algorithm, which must be modified to use boolean unification when unifying two terms of kind U. Suppose... |

219 | Logical frameworks
- Pfenning
- 2001
(Show Context)
Citation Context ...me of the structural rules (in this case, contraction) do not hold. The presentation style we have used, using a context splitting operation, is based on that given in [15], where it is attributed to =-=[16]-=-. The soundness proof for a type system states that when a program is welltyped it will not “go wrong” when evaluated with respect to a given semantics. We are interested in a lazy semantics; often th... |

183 | A natural semantics for lazy evaluation
- Launchbury
- 1993
(Show Context)
Citation Context ... used to prove soundness, but this complicates equational reasoning. Fortunately, it is possible to give an algebraic semantics for lazy evaluation. Launchbury’s natural semantics for lazy evaluation =-=[17]-=- is well-known and concise, but is a big-step semantics which makes it less useful for a soundness proof. The call-by-need semantics by Maraist et al. [4] is slightly more involved, but is a small-ste... |

180 | A system of constructor classes: Overloading and implicit higher-order polymorphism
- Jones
- 1993
(Show Context)
Citation Context ...new concept. For example, they arise in Haskell as type constructors such as the list type constructor ([]). We can make precise which types do and do not classify values by introducing a kind system =-=[5]-=-. Kinds can be regarded as the “types of types”. By definition, the kind of types that classify values is denoted by ∗. In Haskell, we have Int :: *, Bool :: *, but [] :: * → *. The idea of letting th... |

91 | Practical type inference for arbitrary-rank types
- Vytiniotis, Weirich, et al.
- 2005
(Show Context)
Citation Context ... known as Löwenheim’s formula and successive variable elimination [9,10]. For our core system either algorithm will work, but when arbitrary rank types are introduced and we need to use skolemization =-=[11]-=-, only the second is practical. 6 Temporarily using the more common 0 for false (not unique) and 1 for true (unique), to unify two terms p and q it suffices to unify t = (p∧¬q)∨(¬p∧q) = 0. This is imp... |

91 | Is there a use for linear logic
- Wadler
- 1991
(Show Context)
Citation Context ...t a solution similar to the one we propose: subtyping between unique and non-unique terms is fundamental to Harrington’s formalization. Uniqueness typing is often compared to linear (or affine) logic =-=[22]-=-. Although both linear logic and uniqueness typing are substructural logics, there are important differences. In linear logic, variables of a non-linear type can be coercedto a linear type (derelicti... |

87 |
Boolean Reasoning
- Brown
- 1990
(Show Context)
Citation Context ...] t t1 = [x ↦→ 1] t Fig.4. Boolean unification (unify t ≃ 0) There are two well-known algorithms for unification in a boolean algebra, known as Löwenheim’s formula and successive variable elimination =-=[9,10]-=-. For our core system either algorithm will work, but when arbitrary rank types are introduced and we need to use skolemization [11], only the second is practical. 6 Temporarily using the more common ... |

85 | Once upon a type
- Turner, Wadler, et al.
- 1995
(Show Context)
Citation Context ... pointer to it. But if we know this by other means, then linearity guarantees that the pointer will not be duplicated or discarded” [22, Sect. 3]. However, some systems based on linear logic (such as =-=[23]-=-) are much closer to uniqueness typing than to linear logic, and these systems could benefit equally from the techniques presented in this paper (attributes as types, boolean expressions for attribute... |

85 | Engineering Formal Metatheory - Aydemir, Charguéraud, et al. - 2008 |

77 | System F with type equality coercions
- Sulzmann, Chakravarty, et al.
- 2007
(Show Context)
Citation Context ...lassify values is denoted by ∗. In Haskell, we have Int :: *, Bool :: *, but [] :: * → *. The idea of letting the language of vanilla types and additional properties coincide is not new either (e.g., =-=[6, 7]-=-), but as far as the authors are aware it is new in the context of substructural type systems.Kind language κ ::= kind T base type U uniqueness attribute ∗ base type together with a uniqueness attrib... |

73 |
Single-threaded polymorphic lambda calculus
- Guzmán, Hudak
- 1990
(Show Context)
Citation Context ...hese systems could benefit equally from the techniques presented in this paper (attributes as types, boolean expressions for attributes). Finally, Guzmán’s Single-Threaded Polymorphic Lambda Calculus =-=[24]-=- has similar goals to uniqueness typing, but is considerably more complicated. Much of this complexity comes from trying to support a “strict let” construct where unique (or “single-threaded”) terms c... |

70 | Conventional and Uniqueness Typing in Graph Rewrite Systems (extended abstract
- Barendsen, Smetsers
- 1993
(Show Context)
Citation Context ... programmer to decide if they want to treat it as unique or shared (Sect. 6). 2 Contributions of This Paper The type system we present in this paper is based on that of the programming language Clean =-=[1,2]-=-. However, Clean’s type system has a number of drawbacks. – Types and attributes are regarded as two different entities, which limits expressiveness and impedes adding uniqueness typing to existing co... |

42 | The call-by-need lambda calculus
- Maraist, Odersky, et al.
- 1998
(Show Context)
Citation Context ...uthors are aware, this is also the first substructural type system to have these features. – Finally, we prove soundness of our type system in Sect. 8 with respect to the call-by-need lambda calculus =-=[4]-=-. 3 Attributes Are Types In this section, we show that we can regard types and attributes as one syntactic category. This simplifies both the presentation and implementation of a uniqueness type syste... |

40 | Uniqueness typing for functional languages with graph rewriting semantics
- Barendsen, Smetsers
- 1995
(Show Context)
Citation Context ... programmer to decide if they want to treat it as unique or shared (Sect. 6). 2 Contributions of This Paper The type system we present in this paper is based on that of the programming language Clean =-=[1,2]-=-. However, Clean’s type system has a number of drawbacks. – Types and attributes are regarded as two different entities, which limits expressiveness and impedes adding uniqueness typing to existing co... |

31 |
Boxy types: inference for higher-rank types and impredicativity
- Vytiniotis, Weirich, et al.
- 2006
(Show Context)
Citation Context ...’s type system is HMF [12], which is a Hindley/Milner-like type system that supports first class polymorphism (higher rank types and impredicativity). As such, it is an alternative to both Boxy Types =-=[13]-=- and MLF [14]. However, unlike boxy types, it is presented as a small logical system which makes it easier to understand, and at the same time it is much simpler than MLF. Although HMF is quite a good... |

30 |
Substructural type systems
- WALKER
- 2005
(Show Context)
Citation Context ...ructural presentation because some of the structural rules (in this case, contraction) do not hold. The presentation style we have used, using a context splitting operation, is based on that given in =-=[15]-=-, where it is attributed to [16]. The soundness proof for a type system states that when a program is welltyped it will not “go wrong” when evaluated with respect to a given semantics. We are interest... |

24 | Observers for linear types
- Odersky
- 1992
(Show Context)
Citation Context ...ingle-threaded”) terms can be used multiple times at a non-unique (multiple-threaded) type. A detailed discussion of this problem is beyond the scope of this paper; see for example [25, Sect. 9.4] or =-=[26]-=-. 10 Conclusions By treating uniqueness attributes as types of a special kind U, the presentation and implementation of a uniqueness type system is simplified, and we gain expressiveness in the defini... |

22 | Putting Curry-Howard to work
- Sheard
(Show Context)
Citation Context ...lassify values is denoted by ∗. In Haskell, we have Int :: *, Bool :: *, but [] :: * → *. The idea of letting the language of vanilla types and additional properties coincide is not new either (e.g., =-=[6, 7]-=-), but as far as the authors are aware it is new in the context of substructural type systems.Kind language κ ::= kind T base type U uniqueness attribute ∗ base type together with a uniqueness attrib... |

14 | HMF: simple type inference for first-class polymorphism, in
- Leijen
(Show Context)
Citation Context ...e function definition is accepted.7 Implementation in Morrow We have integrated our type system in Morrow, an experimental functional language developed by Daan Leijen. 7 Morrow’s type system is HMF =-=[12]-=-, which is a Hindley/Milner-like type system that supports first class polymorphism (higher rank types and impredicativity). As such, it is an alternative to both Boxy Types [13] and MLF [14]. However... |

10 | ML F : Raising ML to the power of System F
- Botlan, Rémy
(Show Context)
Citation Context ...m is HMF [12], which is a Hindley/Milner-like type system that supports first class polymorphism (higher rank types and impredicativity). As such, it is an alternative to both Boxy Types [13] and MLF =-=[14]-=-. However, unlike boxy types, it is presented as a small logical system which makes it easier to understand, and at the same time it is much simpler than MLF. Although HMF is quite a good fit with our... |

7 | Eekelen. Clean Language Report, Version 2.1 - Plasmeijer, van - 2002 |

5 |
Middelkoop.Ageneric usage analysis with subeffect qualifiers
- Hage, andA
- 2007
(Show Context)
Citation Context ...k; we can only discuss the most relevant.There are two recent papers on uniqueness typing: Harrington [19] presents a categorical semantics for a uniqueness type system like Clean’s, and Hage et al. =-=[20]-=- present a generic type system that can be instantiated to support either sharing analysis or uniqueness typing. In both systems all unique terms can be coerced to non-unique terms. As observed in Sec... |

3 | D.: Uniqueness typing redefined - Vries, Plasmeijer, et al. - 2006 |

2 |
Heap recycling for lazy languages
- Hage, Holdermans
- 2008
(Show Context)
Citation Context ...ors suggest that the problem may be remedied by introducing an additional attribute on arrows, like we suggested in our previous paper (see also Sect. 6)—and they adopt this solution in a later paper =-=[21]-=-. It remains to be seen whether a similar solution to the one we propose in the current paper is possible for their system. The central thesis of their paper is a duality between uniqueness typing and... |

1 | E.: Uniqueness typing simplified—technical appendix
- Vries
(Show Context)
Citation Context ...n Fig. 5.Unfortunately, due to space limitations we can only give a summary of the proof here. A full formal proof, written using the Coq proof assistant, can be found in a separate technical report =-=[18]-=-. Theorem 1 (Progress). Suppose e is a closed, well-typed term (∅ ⊢ e : τ|fv for some τ and fv). Then either e is an answer or there exists some e ′ such that e ↦→ e ′ . Proof. The easiest way to prov... |