Typing Local Definitions and Conditional Expressions with Rank 2 Intersection (Extended Abstract) Ferruccio Damiani Dipartimento di Informatica, Universit`a di Torino, Corso Svizzera 185, 10149 Torino, Italy damiani@di.unito.it http://www.di.unito.it/∼damiani Abstract. We introduce a variant of the system of rank 2 intersec- tion types with new typing rules for local definitions (let-expressions and letrec-expressions) and conditional expressions (if -expressions and case-expressions). These extensions are a further step towards the use of intersection types in “real” programming languages. 1 Introduction The Hindley-Milner type system [3] is the core of the type systems of mod- ern functional programming languages, like ML [11], Miranda, Haskell, and Clean. The fact that this type system is somewhat inflexible 1 has motivated the search for more expressive, but still decidable, type systems (see, for in- stance, [10,14,4,2,8,7,9]). The extensions based on intersection types are partic- ular interesting since they generally have the principal typing property 2 , whose advantages w.r.t. the principal type property 3 of the ML type system have been described in [7]. In particular the system of rank 2 intersection types [10,14,15,7] is able to type all ML programs, has the principal typing property, decidable type inference, and complexity of type inference which is of the same order as in ML. The variant of the system of rank 2 intersection types considered by Jim [7] is particularly interesting since it includes a new rule for typing recur- sive definitions which allows to type some, but not all, examples of polymorphic recursion [12]. In this paper we build on Jim’s work [7] and present a new system of rank 2 intersection types, ⊢ If ,Let,Rec ∧2 , which allows to give more expressive typings to locally defined identifiers (let-bound and letrec-bound identifiers) and to con- ditional expressions (we consider only if -expressions, but the technique can be 1 In particular it does not allow to assign different types to different occurrences of a formal parameter in the body of a function. 2 A type system has the principal typing property if, whenever a term e is typable, there exist a type environment A and a type v representing all possible typings of e . 3 A type system has the principal type property if, whenever a term e is typable in a type environment A, there exists a type v representing all possible types of e in A. J. Tiuryn (Ed.): FOSSACS 2000, LNCS 1784, pp. 82–97, 2000. c Springer-Verlag Berlin Heidelberg 2000