The gradual typing approach to mixing static and dynamic typing
|
|
- Shawn Reeves
- 6 years ago
- Views:
Transcription
1 1 / 38 The gradual typing approach to mixing static and dynamic typing Jeremy G. Siek University of Colorado = Indiana University TFP 2013 at Provo, Utah, May 2013
2 The Goals of Gradual Typing Enjoy the benefits of static & dynamic typing in different parts of the same program. Provide seamless interoperability between the static & dynamic parts. Static Typing Reliability & Efficiency Dynamic Typing Productivity 2 / 38
3 Overview Gradual Typing: Basics History Functions Objects Generics Mutable State The Future 3 / 38
4 How can Static and Dynamic Coexist? 1 def abs(n: int) int: return -n if n<0 else n def dist(x, y): return abs(x - y) 1 Gradual Typing for Functional Languages, Siek and Taha, SFP / 38
5 How can Static and Dynamic Coexist? 2 Consistency: def abs(n: int) int: return -n if n<0 else n T int int T str str def dist(x :, y : ) : return abs(x - y) int T 1 T 3 T 2 T 4 T 1 T 2 T 3 T 4 Type rule for application: Γ e 1 : T 1 T 3 Γ e 2 : T 2 T 1 T 2 Γ e 1 e 2 : T 3 2 Gradual Typing for Functional Languages, Siek and Taha, SFP / 38
6 6 / 38 Properly Catch Static Errors def abs(n: int) int: return -n if n<0 else n x : str = input_string()... abs(x) str int Consistency: T int int T str str T 1 T 3 T 2 T 4 T 1 T 2 T 3 T 4
7 Compiler Performs Cast Insertion def abs(n: int) int: return -n if n<0 else n def dist(x :, y : ) : return abs(x - y : int) : int dist(7 : int, 3 : int ) The dynamic semantics specifies the behavior of casts, e.g., (7 : int ) : int 7 (7 : int ) : str error 7 / 38
8 Overview Gradual Typing: Basics History Functions Objects Generics Mutable State The Future 8 / 38
9 The Prehistory of Gradual Typing Lisp, early 1980 s types as optimization hints Abadi et al., 1991 defined a dynamic type with explicit injection and projection terms. Cartwright & Fagan, 1991 soft typing: static analysis of dynamic programs Henglein, 1992 expressed dynamic casts using an algebra of coercions. Thatte, 1994 introduced implicit casts based on subtyping, which didn t quite work. Findler & Felleisen, 2002 designed contracts for higher-order functions. 9 / 38
10 History of Gradual Typing (Abbreviated) *Siek & Taha, 2006 implicit casts, consistency Herman et al., 2006 space-efficient casts *Siek & Taha, 2007 gradual typing & objects Adobe, 2006 ActionScript becomes gradual Sam TH & Felleisen, 2008 Typed Scheme Wadler & Findler, 2009 the Blame Theorem *Garcia et. al, 2009 space-efficient blame Larry Wall, 2009 Perl 6 becomes gradual Bierman et al, 2010 C# becomes gradual *Ahmed, et al., 2011 gradual typing & generics Hejlsberg, 2012 Microsoft releases TypeScript *Siek et al., 2012 gradual typing & mutable state 10 / 38
11 Overview Gradual Typing: Basics History Functions Objects Generics Mutable State The Future 11 / 38
12 12 / 38 Higher-Order Functions are Hard def deriv(d: float, f: float float) float: return lambda(x:float): (f(x+d)-f(x-d)) / (2.0*d) 1 def g(y): 2 if y > 0: 3 return y**3 - y else: 5 return "yikes" 6 7 deriv(0.01, g)(3.0) 8 deriv(0.01, g)(-3.0)
13 Higher-Order Functions and Blame def deriv(d: float, f: float float) float: return lambda(x:float): (f(x+d)-f(x-d)) / (2.0*d) 1 def g(y): 2 if y > 0: 3 return y**3 - y else: 5 return "yikes" 6 7 deriv(0.01, g)(3.0) 8 deriv(0.01, g)(-3.0) Casting a function creates a wrapper : g : 8 float float λp : float. g (p : float 8 ) : 8 float yikes : str 8 float blame 8 13 / 38
14 14 / 38 Is Gradual Typing Unsound? 3 4 adding type annotations at random places is unsound Matthias Felleisen, PLT Mailing List, June 10, 2008.
15 14 / 38 Is Gradual Typing Unsound? 3 4 adding type annotations at random places is unsound Matthias Felleisen, PLT Mailing List, June 10, Too weak: If e : T, then either e diverges, e v and v : T, or e error.
16 14 / 38 Is Gradual Typing Unsound? 3 4 adding type annotations at random places is unsound Matthias Felleisen, PLT Mailing List, June 10, Too weak: If e : T, then either e diverges, e v and v : T, or e error. Too strong: If e : T, then either e diverges or e v and v : T.
17 Is Gradual Typing Unsound? 3 4 adding type annotations at random places is unsound Matthias Felleisen, PLT Mailing List, June 10, Too weak: If e : T, then either e diverges, e v and v : T, or e error. Too strong: If e : T, then either e diverges or e v and v : T. Just right: If e : T, then either e diverges, e v and v : T, or e blame l where e = C[e : T 1 l T 2 ] and T 1 : T 2. 3 Well-typed Program s Can t be Blamed, Wadler & Findler, ESOP Exploring the Design Space of H.O. Casts, Siek et al., ESOP / 38
18 15 / 38 Blame and Subtyping Wadler & Finder, 2009: int <: int <: int <: T <: T <: T 3 <: T 1 T 2 <: T 4 T 1 T 2 <: T 3 T 4 Siek, Garcia, & Taha, 2009: int <: int T <: T 3 <: T 1 T 2 <: T 4 T 1 T 2 <: T 3 T 4
19 But Wrappers are Not Space Efficient 5 def even(n: int, k: Bool) Bool: if n == 0: return k(true) else: return odd(n - 1, k) def odd(n: int, k: Bool Bool) Bool: if n == 0: return k(false) else: return even(n - 1, k) 5 Space-Efficient Gradual Typing. Herman, et al., TFP / 38
20 17 / 38 Toward Efficient Casts: Reified Wrappers Regular wrappers: v ::=... λx : T. e v : T 1 T 2 T 3 T 4 λx : T 3. (v (x : T 3 T 1 )) : T 2 T 4 Reified wrappers: v ::=... λx : T. e v : T 1 T 2 T 3 T 4 (v 1 : T 1 T 2 T 3 T 4 ) v 2 (v 1 (v 2 : T 3 T 1 )) : T 2 T 4
21 Compressing a Sequence of Casts 6 v : str int int v : int str int int Define an information ordering: T int int str str T 1 T 3 T 2 T 4 T 1 T 2 T 3 T 4 Take the least upper bound to obtain a triple : e : T 1 T 2 T n 1 T n e : T 1 {T 2,..., T n 1 } T n 6 Threesomes, with and without blame. Siek & Wadler, POPL / 38
22 19 / 38 Space Efficiency Notation: e erases the casts from e. Theorem (Space Efficiency) For any program e there is a constant factor c such that if e e, then size(e ) c size( e ).
23 Overview Gradual Typing: Basics History Functions Objects Generics Mutable State The Future 20 / 38
24 21 / 38 Gradual Typing and Subtyping At the heart of most OO languages is a subsumption rule: Γ e : T 1 T 1 <: T 2 Γ e : T 2 Thatte s early attempt at gradual typing didn t use consistency but instead put the dynamic type at the top and bottom of the subtyping relation. T <: <: T
25 22 / 38 The Problem with Subtyping Subtyping is transitive, so we have: str <: <: int str <: int In general, for any types T 1 and T 2 we have T 1 <: T 2. So the type checker accepts all programs! (Even ones that get stuck.)
26 Consistency and Subtyping are Orthogonal 7 Let subtyping deal with object types: [l i : T i i 1..n+m ] <: [l i : T i i 1..n ] <: Let consistency deal with the dynamic type: T Include the subsumption rule T Γ e : T 1 T 1 <: T 2 Γ e : T 2 and use consistency instead of equality: Γ e 1 : T 1 T 3 Γ e 2 : T 2 T 1 T 2 Γ e 1 e 2 : T 3 7 Gradual Typing for Objects, Siek and Taha, ECOOP / 38
27 24 / 38 An Algorithmic Type System The usual trick is to remove the subsumption rule and use subtyping in place of equality. Γ e 1 : T 1 T 3 Γ e 2 : T 2 T 2 <: T 1 Γ e 1 e 2 : T 3 but for gradual typing, this would look like Γ e 1 : T 1 T 3 Γ e 2 : T 2 T 2 <: T 1 T 1 T 1 Γ e 1 e 2 : T 3 which is not syntax directed. We need a relation that composes the two: Γ e 1 : T 1 T 3 Γ e 2 : T 2 T 2 T 1 Γ e 1 e 2 : T 3
28 25 / 38 Consistent-Subtyping T T int int str str T 3 T 1 T 2 T 4 T i T i i 1..n T 1 T 2 T 3 T 4 [l i : T i 1..n+m i ] [l i : T (This is a more direct definition than the one I gave in Gradual Typing for Objects.) i i 1..n ]
29 Overview Gradual Typing: Basics History Functions Objects Generics Mutable State The Future 26 / 38
30 27 / 38 Gradual Typing & Polymorphism Review of System F: T ::=... X. T e ::=... ΛX. e e[t ] (ΛX. e)[t ] e[x:=t ] Γ, X e : T Γ ΛX. e : X. T Γ e : X. T 1 Γ e[t 2 ] : T 1 [X:=T 2 ]
31 Parametric Polymorphism (Generics) Ahmed, Findler, and Wadler proposed a design at STOP Their goals: Seamless interoperability. v : ( X. S) T v[ ] : S[X:= ] T v : S ( X. T ) ΛX. (v : S T ) Retain relational parametricity (i.e., theorems for free). Provide a natural subtyping relation and blame theorem. I helped refine the design for the POPL 2011 paper. 28 / 38
32 Challenges to Parametricity Consider two casts: K = (λx:.λy:.x) : K : m X. Y. X Y X K : l X. Y. X Y Y The second cast should lead to a cast failure. But a naive semantics lets it go through. (K : l X. Y. X Y Y )[int][int] 2 3 (K : l int int int) : int l int 2 29 / 38
33 Enforcement of Parametricity (K : l X. Y. X Y X)[int][int] 2 3 (νx:=int.νy :=int. K : l X Y X) 2 3 (νx:=int.νy :=int. 2 : X l X) 2 (K : l X. Y. X Y Y )[int][int] 2 3 (νx:=int.νy :=int. K : l X Y Y ) 2 3 (νx:=int.νy :=int. 2 : X l Y ) blame l This mechanism should work, but the parametricity theorem is an open problem. 30 / 38
34 Overview Gradual Typing: Basics History Functions Objects Generics Mutable State The Future 31 / 38
35 32 / 38 Gradual Typing & Mutable State Consider ML-style references T ::=... ref T e ::=... ref e e := e!e with a permissive rule for consistency of reference types: T 1 T 2 ref T 1 ref T 2
36 33 / 38 The Standard Semantics Incurs Overhead The Herman TFP 2006 semantics induces overhead, even in statically-typed regions of code. a N v ::=... a v : ref T 1 ref T 2 ref v µ a µ(a := v) if a / dom(µ) { µ(a) µ if v = a!v µ (!v ) : T 1 T 2 µ if v = v : ref T 1 ref T 2 { v 2 µ(a := v 2 ) if v 1 = a v 1 := v 2 µ v 1 := (v 2:T 2 T 1 ) µ if v 1 = v 1 : ref T 1 ref T 2
37 Monotonic References e ::=... ref e e := e!e e := e@t!e@t v ::=... a let r1 = ref (42 : int ) in let r2 = r1 : ref ref int in (!r1@,!r2) ref ref ref int (42 : int, ) (42, int) 34 / 38
38 35 / 38 Standard vs. Monotonic 1 let r1 = ref (1 : int ) in 2 let r2 = r1 : ref ref int in 3 let r3 = r1 : ref ref bool in 4 let x =!r2 in 5 r3 := true; 6 let y =!r3 in 7 (x,y) (1, true) (standard) blame 3 (monotonic)
39 e µ e ref T v µ a a := (v, T )!a µ µ(a) 1 ɛ Monotonic References a := v µ a a := (v, µ(a) 2 ) if a / dom(µ) a : ref T 1 ref T 2 µ error ɛ if T 2 µ(a) 2 a : ref T 1 ref T 2 µ a ɛ if T 2 µ(a) 2 a : ref T 1 ref T 2 µ a a := (e, µ(a) 2 T 2 ) if T 2 µ(a) 2, e = µ(a) 1 : µ(a) 2 µ(a) 2 T 2!a@T µ (µ(a) 1 : µ(a) 2 T ) ɛ a := v@t µ a a := (v : T µ(a) 2, µ(a) 2 ) e µ e µ e µ e e µ e (µ) µ(a)=(e 1, T ) e 1 µ e 1 e µ e (µ(a := (e 1, T ))) 36 / 38
40 Overview Gradual Typing: Basics History Functions Objects Generics Mutable State The Future 37 / 38
41 The Future Gradually-typed Python (Michael Vitousek) Monotonic references with blame (some ideas, not easy) Monotonic objects (draft) Putting it all together, e.g. can we maintain space efficiency with polymorphic blame? (no idea) Parametricity for the Polymorphic Blame Calculus (Amal Ahmed is part way there) Compiling and optimizing gradually-typed programs (e.g. Rastogi, Chaudhuri, and Hosmer, POPL 2012) Questions? 38 / 38
Gradual Typing with Inference
Gradual Typing with Inference Jeremy Siek University of Colorado at Boulder joint work with Manish Vachharajani Overview Motivation Background Gradual Typing Unification-based inference Exploring the Solution
More informationGradual Typing for Mutable Objects
Gradual Typing for Mutable Objects Jeremy G. Siek 1, Michael M. Vitousek 2, and Shashank Bharadwaj 1 1 Department of Electrical, Computer, and Energy Engineering 2 Department of Computer Science University
More informationJeremy Siek University of Colorado. Blame Tracking JOINT WORK WITH PHILIP WADLER
Jeremy Siek University of Colorado Blame Tracking JOINT WORK WITH PHILIP WADLER an explosive combination! dynamic languages are great! software libraries are great! the combination is explosive! IT S HAPPENED
More informationConsistent Subtyping for All
Consistent Subtyping for All Ningning Xie Xuan Bi Bruno C. d. S. Oliveira 11 May, 2018 The University of Hong Kong 1 Background There has been ongoing debate about which language paradigm, static typing
More information2 Blending static and dynamic typing
2 Blending static and dynamic typing We begin this chapter presenting a little bit of the history behind combining static and dynamic typing in the same language. Then, we introduce optional type systems
More informationExploring the Design Space of Higher-Order Casts ; CU-CS
University of Colorado, Boulder CU Scholar Computer Science Technical Reports Computer Science Fall 10-1-2008 Exploring the Design Space of Higher-Order Casts ; CU-CS-1047-08 Jeremy Siek University of
More informationThe Polymorphic Blame Calculus and Parametricity
1 / 31 The Polymorphic Blame Calculus and Parametricity Jeremy G. Siek Indiana University, Bloomington University of Strathclyde August 2015 2 / 31 Integrating static and dynamic typing Static Dynamic
More informationInterlanguage Migration
Interlanguage Migration From Scripts to Programs Sam Tobin-Hochstadt and Matthias Felleisen Northeastern University DLS 2006 1 A Story 2 About a programmer 3 Who needed to manage his budget 4 And so, he
More informationDesign and Evaluation of Gradual Typing for Python
Design and Evaluation of Gradual Typing for Python Michael M. Vitousek Andrew M. Kent Jeremy G. Siek Jim Baker Indiana University Bloomington Rackspace, Inc. October 21, 2014 1 / 18 Gradual typing def
More informationSpace-Efficient Blame Tracking for Gradual Types
Space-Efficient Blame Tracking for Gradual Types Jeremy G. Siek University of Colorado at Boulder jeremy.siek@colorado.edu Abstract Static and dynamic type systems have well-known strengths and weaknesses.
More informationRefined Criteria for Gradual Typing
Refined Criteria for Gradual Typing Jeremy G. Siek 1, Michael M. Vitousek 1, Matteo Cimini 1, and John Tang Boyland 2 1 Indiana University Bloomington, School of Informatics and Computing 150 S. Woodlawn
More informationBlame, coercions, and threesomes, precisely
Blame, coercions, and threesomes, precisely Jeremy Siek Indiana University jsiek@indiana.edu Peter Thiemann Universität Freiburg thiemann@informatik.uni-freiburg.de Philip Wadler University of Edinburgh
More informationSound Gradual Typing is Nominally Alive and Well
Sound Gradual Typing is Nominally Alive and Well FABIAN MUEHLBOECK, Cornell University, USA ROSS TATE, Cornell University, USA Recent research has identified significant performance hurdles that sound
More informationRecursive Types and Subtyping
Recursive Types and Subtyping #1 One-Slide Summary Recall: Recursive types (e.g., τ list) make the typed lambda calculus as powerful as the untyped lambda calculus. If τ is a subtype of σ then any expression
More informationRecursive Types and Subtyping
Recursive Types and Subtyping #1 One-Slide Summary Recursive types (e.g., list) make the typed lambda calculus as powerful as the untyped lambda calculus. If is a subtype of then any expression of type
More informationGradual Typing for Functional Languages. Jeremy Siek and Walid Taha (presented by Lindsey Kuper)
Gradual Typing for Functional Languages Jeremy Siek and Walid Taha (presented by Lindsey Kuper) 1 Introduction 2 What we want Static and dynamic typing: both are useful! (If you re here, I assume you agree.)
More informationOn Polymorphic Gradual Typing
On Polymorphic Gradual Typing YUU IGARASHI, Kyoto University TARO SEKIYAMA, IBM Research - Tokyo ATSUSHI IGARASHI, Kyoto University We study an extension of gradual typing a method to integrate dynamic
More informationGradual Typing with Union and Intersection Types
Gradual Typing with Union and Intersection Types Giuseppe Castagna, Victor Lanvin ICFP 17 September 6, 2017 1 / 14 Outline 1 Motivating Example 2 Types and Subtyping 3 Function Types and Operators 4 Conclusion
More informationGradual Parametricity, Revisited
aaachicbvddssmwge39nfov6qu30sf4y2lfuerk6i3etbbys0jtdmtle1lkgqj7nrh8am81sfwtrwvh8d3mo12ozshkpyc7zvkywlsrqwy7s9jbn5hcwm5sljdvvf2ds3tlsyyqqmtzywrlgbkorrtpqkkkbcvbaub4y0g8f1uw8/ecfpwu/vmcv+jhqcrhqjpawuuedfiucmqdecljy61nvfofruusouxdk1a7zll4czxjmqgpig0tw/vtdbwuy4wgxj2hsvpk5eopirkzvl5mkriaeqsjkucxk5efmued7qsqj2tnqguv3tyfes5taodgemvf9o1wrxv1onu9gzn1oezopwph4oyhhucsxygsevbcs21arhqfwseperqfjp9kpeacxdelfoi+tksofitkcws1rhlmnbzt1jr41sagcdse+oaqooav1camaoakweatp4aw8gk/gm/fufixb54yjzwf8gfh5a4h9n/m=
More informationFROM SCRIPTS TO PROGRAMS OR, TYPES FOR UNTYPED LANGUAGES. Matthias Felleisen Racketeer
FROM SCRIPTS TO PROGRAMS OR, TYPES FOR UNTYPED LANGUAGES Matthias Felleisen Racketeer THE PROGRAMMING LANGUAGE RENAISSANCE performance PL performance Java/JVM C#/CIL Scala, F# PL safety & security EmacsLISP
More informationWell-typed programs can t be blamed
Well-typed programs can t be blamed Philip Wadler University of Edinburgh Robert Bruce Findler University of Chicago Abstract We show how contracts with blame fit naturally with recent work on hybrid types
More informationTypes and Type Inference
Types and Type Inference Mooly Sagiv Slides by Kathleen Fisher and John Mitchell Reading: Concepts in Programming Languages, Revised Chapter 6 - handout on the course homepage Outline General discussion
More informationTyped Scheme From Scripts to Programs. Sam Tobin-Hochstadt Northeastern University
Typed Scheme From Scripts to Programs Sam Tobin-Hochstadt Northeastern University 1 The PL Renaissance 2 The PL Renaissance 3 The PL Renaissance 4 What s good These languages are interactive designed for
More informationSubtyping. Lecture 13 CS 565 3/27/06
Subtyping Lecture 13 CS 565 3/27/06 Polymorphism Different varieties of polymorphism: Parametric (ML) type variables are abstract, and used to encode the fact that the same term can be used in many different
More informationEdinburgh Research Explorer
Edinburgh Research Explorer Well-Typed Programs Can't Be Blamed Citation for published version: Wadler, P & Findler, RB 2009, Well-Typed Programs Can't Be Blamed. in G Castagna (ed.), Programming Languages
More informationDesign by Contract: An Overview
: An Overview CSCI 5828 Michael M. Vitousek University of Colorado at Boulder michael.vitousek@colorado.edu March 21, 2012 1 / 35 Outline 1 Introduction Motivation and Introduction Simple Example Contract
More informationTypes for References, Exceptions and Continuations. Review of Subtyping. Γ e:τ τ <:σ Γ e:σ. Annoucements. How s the midterm going?
Types for References, Exceptions and Continuations Annoucements How s the midterm going? Meeting 21, CSCI 5535, Spring 2009 2 One-Slide Summary Review of Subtyping If τ is a subtype of σ then any expression
More informationCMSC 631 Program Analysis and Understanding. Dynamic Typing, Contracts, and Gradual Typing
CMSC 631 Program Analysis and Understanding Dynamic Typing, Contracts, and Gradual Typing Static vs. Dynamic Typing Languages with Static Typing Examples: Ocaml, Java, C#, Scala, Haskell Typechecker proves
More informationProgramming Languages Lecture 15: Recursive Types & Subtyping
CSE 230: Winter 2008 Principles of Programming Languages Lecture 15: Recursive Types & Subtyping Ranjit Jhala UC San Diego News? Formalize first-order type systems Simple types (integers and booleans)
More informationHarvard School of Engineering and Applied Sciences CS 152: Programming Languages
Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Lecture 24 Thursday, April 19, 2018 1 Error-propagating semantics For the last few weeks, we have been studying type systems.
More informationHarvard School of Engineering and Applied Sciences CS 152: Programming Languages
Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Lecture 18 Thursday, April 3, 2014 1 Error-propagating semantics For the last few weeks, we have been studying type systems.
More informationSpace-Efficient Gradual Typing
Space-Efficient Gradual Typing David Herman 1, Aaron Tomb 2, and Cormac Flanagan 2 1 Northeastern University 2 University of California, Santa Cruz Abstract Gradual type systems offer a smooth continuum
More informationHarvard School of Engineering and Applied Sciences CS 152: Programming Languages
Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Lecture 14 Tuesday, March 24, 2015 1 Parametric polymorphism Polymorph means many forms. Polymorphism is the ability of
More informationGoal. CS152: Programming Languages. Lecture 15 Parametric Polymorphism. What the Library Likes. What The Client Likes. Start simpler.
Goal Understand what this interface means and why it matters: CS152: Programming Languages Lecture 15 Parametric Polymorphism Dan Grossman Spring 2011 type a mylist; val mt_list : a mylist val cons : a
More informationVerifying Program Invariants with Refinement Types
Verifying Program Invariants with Refinement Types Rowan Davies and Frank Pfenning Carnegie Mellon University Princeton and Yale Colloquium Talks February, 2001 Acknowledgments: Robert Harper 1 Overview
More informationHarvard School of Engineering and Applied Sciences Computer Science 152
Harvard School of Engineering and Applied Sciences Computer Science 152 Lecture 17 Tuesday, March 30, 2010 1 Polymorph means many forms. Polymorphism is the ability of code to be used on values of different
More informationCSE-505: Programming Languages. Lecture 20.5 Recursive Types. Zach Tatlock 2016
CSE-505: Programming Languages Lecture 20.5 Recursive Types Zach Tatlock 2016 Where are we System F gave us type abstraction code reuse strong abstractions different from real languages (like ML), but
More informationTypes. Type checking. Why Do We Need Type Systems? Types and Operations. What is a type? Consensus
Types Type checking What is a type? The notion varies from language to language Consensus A set of values A set of operations on those values Classes are one instantiation of the modern notion of type
More informationConsistent Subtyping for All
Consistent Subtyping for All Ningning Xie, Xuan Bi, and Bruno C. d. S. Oliveira The University of Hong Kong {nnxie,xbi,bruno}@cs.hku.hk Abstract. Consistent subtyping is employed in some gradual type systems
More informationCS-XXX: Graduate Programming Languages. Lecture 17 Recursive Types. Dan Grossman 2012
CS-XXX: Graduate Programming Languages Lecture 17 Recursive Types Dan Grossman 2012 Where are we System F gave us type abstraction code reuse strong abstractions different from real languages (like ML),
More informationTopics Covered Thus Far. CMSC 330: Organization of Programming Languages. Language Features Covered Thus Far. Programming Languages Revisited
CMSC 330: Organization of Programming Languages Type Systems, Names & Binding Topics Covered Thus Far Programming languages Syntax specification Regular expressions Context free grammars Implementation
More informationCS-XXX: Graduate Programming Languages. Lecture 9 Simply Typed Lambda Calculus. Dan Grossman 2012
CS-XXX: Graduate Programming Languages Lecture 9 Simply Typed Lambda Calculus Dan Grossman 2012 Types Major new topic worthy of several lectures: Type systems Continue to use (CBV) Lambda Caluclus as our
More informationSpace-efficient gradual typing
Higher-Order Symb Comput (2010) 23:167 189 DOI 10.1007/s10990-011-9066-z Space-efficient gradual typing David Herman Aaron Tomb Cormac Flanagan Published online: 21 October 2011 Springer Science+Business
More informationTradeoffs. CSE 505: Programming Languages. Lecture 15 Subtyping. Where shall we add useful completeness? Where shall we add completeness?
Tradeoffs CSE 505: Programming Languages Lecture 15 Subtyping Zach Tatlock Autumn 2017 Desirable type system properties (desiderata): soundness - exclude all programs that get stuck completeness - include
More informationTypes, Type Inference and Unification
Types, Type Inference and Unification Mooly Sagiv Slides by Kathleen Fisher and John Mitchell Cornell CS 6110 Summary (Functional Programming) Lambda Calculus Basic ML Advanced ML: Modules, References,
More informationLecture #23: Conversion and Type Inference
Lecture #23: Conversion and Type Inference Administrivia. Due date for Project #2 moved to midnight tonight. Midterm mean 20, median 21 (my expectation: 17.5). Last modified: Fri Oct 20 10:46:40 2006 CS164:
More informationTopic 9: Type Checking
Recommended Exercises and Readings Topic 9: Type Checking From Haskell: The craft of functional programming (3 rd Ed.) Exercises: 13.17, 13.18, 13.19, 13.20, 13.21, 13.22 Readings: Chapter 13.5, 13.6 and
More informationTopic 9: Type Checking
Topic 9: Type Checking 1 Recommended Exercises and Readings From Haskell: The craft of functional programming (3 rd Ed.) Exercises: 13.17, 13.18, 13.19, 13.20, 13.21, 13.22 Readings: Chapter 13.5, 13.6
More informationG Programming Languages Spring 2010 Lecture 6. Robert Grimm, New York University
G22.2110-001 Programming Languages Spring 2010 Lecture 6 Robert Grimm, New York University 1 Review Last week Function Languages Lambda Calculus SCHEME review 2 Outline Promises, promises, promises Types,
More informationConversion vs. Subtyping. Lecture #23: Conversion and Type Inference. Integer Conversions. Conversions: Implicit vs. Explicit. Object x = "Hello";
Lecture #23: Conversion and Type Inference Administrivia. Due date for Project #2 moved to midnight tonight. Midterm mean 20, median 21 (my expectation: 17.5). In Java, this is legal: Object x = "Hello";
More informationCMSC 330: Organization of Programming Languages
CMSC 330: Organization of Programming Languages Type Systems, Names and Binding CMSC 330 - Spring 2013 1 Topics Covered Thus Far! Programming languages Ruby OCaml! Syntax specification Regular expressions
More informationOverloading, Type Classes, and Algebraic Datatypes
Overloading, Type Classes, and Algebraic Datatypes Delivered by Michael Pellauer Arvind Computer Science and Artificial Intelligence Laboratory M.I.T. September 28, 2006 September 28, 2006 http://www.csg.csail.mit.edu/6.827
More informationSimply-Typed Lambda Calculus
#1 Simply-Typed Lambda Calculus #2 Back to School What is operational semantics? When would you use contextual (small-step) semantics? What is denotational semantics? What is axiomatic semantics? What
More informationInterlanguage Migration: From Scripts to Programs
Interlanguage Migration: From Scripts to Programs Sam Tobin-Hochstadt Northeastern University Boston, MA samth@ccs.neu.edu Matthias Felleisen Northeastern University Boston, MA matthias@ccs.neu.edu ABSTRACT
More informationProgramming Languages
CSE 230: Winter 2008 Principles of Programming Languages Ocaml/HW #3 Q-A Session Push deadline = Mar 10 Session Mon 3pm? Lecture 15: Type Systems Ranjit Jhala UC San Diego Why Typed Languages? Development
More informationTopics Covered Thus Far CMSC 330: Organization of Programming Languages
Topics Covered Thus Far CMSC 330: Organization of Programming Languages Names & Binding, Type Systems Programming languages Ruby Ocaml Lambda calculus Syntax specification Regular expressions Context free
More informationCSCI-GA Scripting Languages
CSCI-GA.3033.003 Scripting Languages 12/02/2013 OCaml 1 Acknowledgement The material on these slides is based on notes provided by Dexter Kozen. 2 About OCaml A functional programming language All computation
More informationLambda Calculi With Polymorphism
Resources: The slides of this lecture were derived from [Järvi], with permission of the original author, by copy & x = 1 let x = 1 in... paste or by selection, annotation, or rewording. [Järvi] is in turn
More informationPierce Ch. 3, 8, 11, 15. Type Systems
Pierce Ch. 3, 8, 11, 15 Type Systems Goals Define the simple language of expressions A small subset of Lisp, with minor modifications Define the type system of this language Mathematical definition using
More informationCast Insertion Strategies for Gradually-Typed Objects
Cast Insertion Strategies for Gradually-Typed Objects Esteban Allende Johan Fabry Éric Tanter PLEIAD Laboratory Computer Science Department (DCC) University of Chile {eallende,jfabry,etanter}@dcc.uchile.cl
More informationBlame for All. Robert Bruce Findler. Amal Ahmed. Jeremy G. Siek. Philip Wadler. Abstract. 1. Introduction
Blame for All Amal Ahmed Indiana University amal@cs.indiana.edu Robert Bruce Findler Northwestern University robby@eecs.northwestern.edu Jeremy G. Siek University of Colorado at Boulder jeremy.siek@colorado.edu
More informationPart VI. Imperative Functional Programming
Part VI Imperative Functional Programming Chapter 14 Mutable Storage MinML is said to be a pure language because the execution model consists entirely of evaluating an expression for its value. ML is
More informationParametric types. map: ( a (a b) a list b list. filter: ( a bool) a list a list. Why? a and b are type variables!
What is the deal with a? Parametric types aka: what s up with those a? These meta-functions have strange types: map: ( a b) a list b list filter: ( a bool) a list a list Why? Polymorphism Poly = many,
More informationCSE-321 Programming Languages 2010 Final
Name: Hemos ID: CSE-321 Programming Languages 2010 Final Prob 1 Prob 2 Prob 3 Prob 4 Prob 5 Prob 6 Total Score Max 18 28 16 12 36 40 150 There are six problems on 16 pages, including two work sheets, in
More informationCSCE 314 Programming Languages. Type System
CSCE 314 Programming Languages Type System Dr. Hyunyoung Lee 1 Names Names refer to different kinds of entities in programs, such as variables, functions, classes, templates, modules,.... Names can be
More informationLinking Types: Secure compilation of multi-language programs
Linking Types: Secure compilation of multi-language programs Daniel Patterson and Amal Ahmed January 15, 2017 Northeastern University Fully abstract compilers Source program fully abstract compiler Compiled
More informationType Checking and Type Inference
Type Checking and Type Inference Principles of Programming Languages CSE 307 1 Types in Programming Languages 2 Static Type Checking 3 Polymorphic Type Inference Version: 1.8 17:20:56 2014/08/25 Compiled
More informationDYNAMIC TYPING WITH DEPENDENT TYPES
DYNAMIC TYPING WITH DEPENDENT TYPES Xinming Ou, Gang Tan, Yitzhak Mandelbaum and David Walker Department of Computer Science Princeton University {xou,gtan,yitzhakm,dpw}@cs.princeton.edu Abstract Dependent
More informationA Blame for All (revised)
A Blame for All (revised) Amal Ahmed, Northeastern University James T. Perconti, Northeastern University Jeremy G. Siek, Indiana University Philip Wadler, University of Edinburgh Several programming languages
More informationPart III. Chapter 15: Subtyping
Part III Chapter 15: Subtyping Subsumption Subtype relation Properties of subtyping and typing Subtyping and other features Intersection and union types Subtyping Motivation With the usual typing rule
More informationPrincipal Type Schemes for Gradual Programs
Principal Type Schemes for Gradual Programs With updates and corrections since publication (Latest: May 16, 2017) Ronald Garcia Software Practices Lab Department of Computer Science University of British
More informationOutline. Introduction Concepts and terminology The case for static typing. Implementing a static type system Basic typing relations Adding context
Types 1 / 15 Outline Introduction Concepts and terminology The case for static typing Implementing a static type system Basic typing relations Adding context 2 / 15 Types and type errors Type: a set of
More informationPolymorphism and Type Inference
Polymorphism and Type Inference Volker Stolz stolz@ifi.uio.no Department of Informatics University of Oslo Initially by Gerardo Schneider. Based on John C. Mitchell s slides (Stanford U.) Compile-time
More informationCSE 505, Fall 2008, Final Examination 11 December Please do not turn the page until everyone is ready.
CSE 505, Fall 2008, Final Examination 11 December 2008 Please do not turn the page until everyone is ready. Rules: The exam is closed-book, closed-note, except for one side of one 8.5x11in piece of paper.
More informationSpace-Efficient Gradual Typing
Space-Efficient Gradual Typing David Herman 1, Aaron Tomb 2, and Cormac Flanagan 2 1 Northeastern University 2 University of California, Santa Cruz Abstract Gradual type systems offer a smooth continuum
More information` e : T. Gradual Typing. ` e X. Ronald Garcia University of British Columbia
aaab/hicbvbns8naen34wetxtecvi0xwvbirfe9fd3qs0c9oqplsnu3s3stsbgqh1l/ixymixv0h3vw3btsctpxbwoo9gwbmbslnsjvot7w2vrg5tv3ake/u7r8c2kfhbzvkktawsxgiuweoyllmw5pptruppcactjvb6g7md8zukpbetz2n1bcwifnecggj9e2kdw9capbgiaghpvggn/t21ak5c+bv4hakigo0+vaxfyykeztwhinspddjtt8bqrnhdfr2mkvticmy0j6hmqiq/mn8+ck+m0qio0saijweq78njicuykvgogxoovr2zuj/xi/t0bu/yxgaarqtxaio41gnejyedpmkrppceccsmvsxgyieok1ezrocu/zykmlf1fyn5j5evuu3rrwldijo0tly0rwqowfuqc1eui6e0st6s56sf+vd+li0rlnftax9gfx5a8zmk40=
More informationCSE341: Programming Languages Lecture 11 Type Inference. Dan Grossman Spring 2016
CSE341: Programming Languages Lecture 11 Type Inference Dan Grossman Spring 2016 Type-checking (Static) type-checking can reject a program before it runs to prevent the possibility of some errors A feature
More informationLecture 13: Subtyping
Lecture 13: Subtyping Polyvios Pratikakis Computer Science Department, University of Crete Type Systems and Programming Languages Pratikakis (CSD) Subtyping CS546, 2018-2019 1 / 15 Subtyping Usually found
More informationCSCI B522 Lecture 11 Naming and Scope 8 Oct, 2009
CSCI B522 Lecture 11 Naming and Scope 8 Oct, 2009 Lecture notes for CS 6110 (Spring 09) taught by Andrew Myers at Cornell; edited by Amal Ahmed, Fall 09. 1 Static vs. dynamic scoping The scope of a variable
More informationTypes and Type Inference
CS 242 2012 Types and Type Inference Notes modified from John Mitchell and Kathleen Fisher Reading: Concepts in Programming Languages, Revised Chapter 6 - handout on Web!! Outline General discussion of
More informationAn update on XML types
An update on XML types Alain Frisch INRIA Rocquencourt (Cristal project) Links Meeting - Apr. 2005 Plan XML types 1 XML types 2 3 2/24 Plan XML types 1 XML types 2 3 3/24 Claim It is worth studying new
More informationLambda Calculi With Polymorphism
Resources: The slides of this lecture were derived from [Järvi], with permission of the original author, by copy & x = 1 let x = 1 in... paste or by selection, annotation, or rewording. [Järvi] is in turn
More informationProgramming Languages Lecture 14: Sum, Product, Recursive Types
CSE 230: Winter 200 Principles of Programming Languages Lecture 4: Sum, Product, Recursive Types The end is nigh HW 3 No HW 4 (= Final) Project (Meeting + Talk) Ranjit Jhala UC San Diego Recap Goal: Relate
More informationPart III Chapter 15: Subtyping
Part III Chapter 15: Subtyping Subsumption Subtype relation Properties of subtyping and typing Subtyping and other features Intersection and union types Subtyping Motivation With the usual typing rule
More informationCSE 505, Fall 2008, Final Examination 11 December Please do not turn the page until everyone is ready.
CSE 505, Fall 2008, Final Examination 11 December 2008 Please do not turn the page until everyone is ready. Rules: The exam is closed-book, closed-note, except for one side of one 8.5x11in piece of paper.
More informationFormal Systems and their Applications
Formal Systems and their Applications Dave Clarke (Dave.Clarke@cs.kuleuven.be) Acknowledgment: these slides are based in part on slides from Benjamin Pierce and Frank Piessens 1 Course Overview Introduction
More informationSecond-Order Type Systems
#1 Second-Order Type Systems Homework 5 Summary Student : 37.9704 Student : 44.4466 ORIGINAL : 50.2442 Student : 50.8275 Student : 50.8633 Student : 50.9181 Student : 52.1347 Student : 52.1633 Student
More informationWe defined congruence rules that determine the order of evaluation, using the following evaluation
CS 4110 Programming Languages and Logics Lectures #21: Advanced Types 1 Overview In this lecture we will extend the simply-typed λ-calculus with several features we saw earlier in the course, including
More informationUnifying Nominal and Structural Ad-Hoc Polymorphism
Unifying Nominal and Structural Ad-Hoc Polymorphism Stephanie Weirich University of Pennsylvania Joint work with Geoff Washburn Ad-hoc polymorphism Define operations that can be used for many types of
More informationCS 6110 S11 Lecture 25 Typed λ-calculus 6 April 2011
CS 6110 S11 Lecture 25 Typed λ-calculus 6 April 2011 1 Introduction Type checking is a lightweight technique for proving simple properties of programs. Unlike theorem-proving techniques based on axiomatic
More informationcs242 Kathleen Fisher Reading: Concepts in Programming Languages, Chapter 6 Thanks to John Mitchell for some of these slides.
cs242 Kathleen Fisher Reading: Concepts in Programming Languages, Chapter 6 Thanks to John Mitchell for some of these slides. We are looking for homework graders. If you are interested, send mail to cs242cs.stanford.edu
More informationSubsumption. Principle of safe substitution
Recap on Subtyping Subsumption Some types are better than others, in the sense that a value of one can always safely be used where a value of the other is expected. Which can be formalized as by introducing:
More informationTypes. What is a type?
Types What is a type? Type checking Type conversion Aggregates: strings, arrays, structures Enumeration types Subtypes Types, CS314 Fall 01 BGRyder 1 What is a type? A set of values and the valid operations
More informationType Inference. Prof. Clarkson Fall Today s music: Cool, Calm, and Collected by The Rolling Stones
Type Inference Prof. Clarkson Fall 2016 Today s music: Cool, Calm, and Collected by The Rolling Stones Review Previously in 3110: Interpreters: ASTs, evaluation, parsing Formal syntax Formal semantics
More information1 Introduction. 3 Syntax
CS 6110 S18 Lecture 19 Typed λ-calculus 1 Introduction Type checking is a lightweight technique for proving simple properties of programs. Unlike theorem-proving techniques based on axiomatic semantics,
More informationStatic Contract Checking for Haskell
Static Contract Checking for Haskell Dana N. Xu INRIA France Work done at University of Cambridge Simon Peyton Jones Microsoft Research Cambridge Joint work with Koen Claessen Chalmers University of Technology
More informationLike Types. aka. integrating typed and untyped code in Thorn. Francesco Zappa Nardelli. INRIA Paris-Rocquencourt, MOSCOVA research team
Like Types aka. integrating typed and untyped code in Thorn Francesco Zappa Nardelli INRIA Paris-Rocquencourt, MOSCOVA research team Tobias Wrigstad Sylvain Lebresne Johan Östlund Jan Vitek Purdue University
More informationCS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Dan Grossman Spring 2011
CS152: Programming Languages Lecture 11 STLC Extensions and Related Topics Dan Grossman Spring 2011 Review e ::= λx. e x e e c v ::= λx. e c τ ::= int τ τ Γ ::= Γ, x : τ (λx. e) v e[v/x] e 1 e 1 e 1 e
More informationA Spectrum of Type Soundness and Performance. Ben Greenman & Matthias Felleisen Northeastern University
A Spectrum of Type Soundness and Performance Ben Greenman & Matthias Felleisen Northeastern University Is type soundness all-or-nothing? Can adding types slow down a program? Migratory Typing Typed/Untyped
More informationSemantic Analysis. Outline. The role of semantic analysis in a compiler. Scope. Types. Where we are. The Compiler Front-End
Outline Semantic Analysis The role of semantic analysis in a compiler A laundry list of tasks Scope Static vs. Dynamic scoping Implementation: symbol tables Types Static analyses that detect type errors
More information