spine local type inference
play

Spine-local Type Inference Christopher Jenkins and Aaron Stump - PowerPoint PPT Presentation

Spine-local Type Inference Christopher Jenkins and Aaron Stump Computer Science University of Iowa IFL 18 Jenkins, Stump (CS, U. Iowa) Spine-local Type Inference IFL 18 1 / 33 Outline Background and Motivation 1 Local Type


  1. Spine-local Type Inference Christopher Jenkins and Aaron Stump Computer Science University of Iowa IFL ’18 Jenkins, Stump (CS, U. Iowa) Spine-local Type Inference IFL ’18 1 / 33

  2. Outline Background and Motivation 1 Local Type Inference Spine-local Type Inference The Specificational System 2 Terms and Terminology Type Inference Discussion 3 Specificational System Properties Algorithmic System Properties Future Work Jenkins, Stump (CS, U. Iowa) Spine-local Type Inference IFL ’18 2 / 33

  3. Outline Background and Motivation 1 Local Type Inference Spine-local Type Inference The Specificational System 2 Terms and Terminology Type Inference Discussion 3 Specificational System Properties Algorithmic System Properties Future Work Jenkins, Stump (CS, U. Iowa) Spine-local Type Inference IFL ’18 3 / 33

  4. What is “Local Type Inference”? Introduced by Pierce and Turner in ’98 Extended by Odersky et al. in ’01 Uses two main techniques ◮ Bidirectional typing rules: ◮ Local type-argument inference: Jenkins, Stump (CS, U. Iowa) Spine-local Type Inference IFL ’18 4 / 33

  5. What is “Local Type Inference”? Introduced by Pierce and Turner in ’98 Extended by Odersky et al. in ’01 Uses two main techniques ◮ Bidirectional typing rules: Synthesis mode: λ x : Nat . x ⇑ Nat → Nat Checking mode: λ x . x ⇓ Nat → Nat ◮ Local type-argument inference: Jenkins, Stump (CS, U. Iowa) Spine-local Type Inference IFL ’18 4 / 33

  6. What is “Local Type Inference”? Introduced by Pierce and Turner in ’98 Extended by Odersky et al. in ’01 Uses two main techniques ◮ Bidirectional typing rules: Synthesis mode: λ x : Nat . x ⇑ Nat → Nat Checking mode: λ x . x ⇓ Nat → Nat ◮ Local type-argument inference: Let id : ∀ X . X → X Type id 0 ⇑ Nat Infer X = Nat from 0 Local and Synthetic Jenkins, Stump (CS, U. Iowa) Spine-local Type Inference IFL ’18 4 / 33

  7. Why use local type inference? It is a method of partial type inference ◮ Complete type inference: no annotations ever (e.g. Damas-Hindley-Milner and ML) ◮ Undecidable for System F and beyond Jenkins, Stump (CS, U. Iowa) Spine-local Type Inference IFL ’18 5 / 33

  8. Why use local type inference? It is a method of partial type inference ◮ Complete type inference: no annotations ever (e.g. Damas-Hindley-Milner and ML) ◮ Undecidable for System F and beyond It is user-friendly ◮ Infers many type annotations ◮ Predictable annotation requirements ◮ Better-quality error messages Jenkins, Stump (CS, U. Iowa) Spine-local Type Inference IFL ’18 5 / 33

  9. Why use local type inference? It is a method of partial type inference ◮ Complete type inference: no annotations ever (e.g. Damas-Hindley-Milner and ML) ◮ Undecidable for System F and beyond It is user-friendly ◮ Infers many type annotations ◮ Predictable annotation requirements ◮ Better-quality error messages It is implementer-friendly ◮ Relatively simple implementation ◮ Extensible : new features added without threatening decidability Jenkins, Stump (CS, U. Iowa) Spine-local Type Inference IFL ’18 5 / 33

  10. Limitations Local type inference in its published form can sometimes still require “silly” type annotations, i.e. those for which there should be enough contextual information to omit Let pair : ∀ X , Y . X → Y → X × Y Type pair ( λ x . x ) 0 Jenkins, Stump (CS, U. Iowa) Spine-local Type Inference IFL ’18 6 / 33

  11. Limitations Local type inference in its published form can sometimes still require “silly” type annotations, i.e. those for which there should be enough contextual information to omit Let pair : ∀ X , Y . X → Y → X × Y Type pair ( λ x . x ) 0 ⇑ ??? We do not expect to locally synthesize a type Jenkins, Stump (CS, U. Iowa) Spine-local Type Inference IFL ’18 6 / 33

  12. Limitations Local type inference in its published form can sometimes still require “silly” type annotations, i.e. those for which there should be enough contextual information to omit Let pair : ∀ X , Y . X → Y → X × Y Type pair ( λ x . x ) 0 ⇑ ??? We do not expect to locally synthesize a type Jenkins, Stump (CS, U. Iowa) Spine-local Type Inference IFL ’18 6 / 33

  13. Limitations Local type inference in its published form can sometimes still require “silly” type annotations, i.e. those for which there should be enough contextual information to omit Let pair : ∀ X , Y . X → Y → X × Y Type pair ( λ x . x ) 0 ⇑ ??? Type pair ( λ x . x ) 0 ⇓ Nat → Nat × Nat We do not expect to locally synthesize a type ... but we would expect to check it against a type Jenkins, Stump (CS, U. Iowa) Spine-local Type Inference IFL ’18 6 / 33

  14. Limitations Local type inference in its published form can sometimes still require “silly” type annotations, i.e. those for which there should be enough contextual information to omit Let pair : ∀ X , Y . X → Y → X × Y Type pair ( λ x . x ) 0 ⇑ ??? Type pair ( λ x . x ) 0 ⇓ Nat → Nat × Nat We do not expect to locally synthesize a type ... but we would expect to check it against a type ◮ We could call this “contextual” type-argument inference. Jenkins, Stump (CS, U. Iowa) Spine-local Type Inference IFL ’18 6 / 33

  15. Limitations Local type inference in its published form can sometimes still require “silly” type annotations, i.e. those for which there should be enough contextual information to omit Let pair : ∀ X , Y . X → Y → X × Y Type pair ( λ x . x ) 0 ⇑ ??? Type pair ( λ x . x ) 0 ⇓ Nat → Nat × Nat We do not expect to locally synthesize a type ... but we would expect to check it against a type ◮ We could call this “contextual” type-argument inference. Unfortunately, this is not done in the two major published systems ◮ Popular “unofficial” extension (used in e.g. Scala, Rust) Jenkins, Stump (CS, U. Iowa) Spine-local Type Inference IFL ’18 6 / 33

  16. Limitations (cont.) Usually uses “fully-uncurried” function applications f ( t 1 , .., t n ) ◮ Maximize available info at a single application Jenkins, Stump (CS, U. Iowa) Spine-local Type Inference IFL ’18 7 / 33

  17. Limitations (cont.) Usually uses “fully-uncurried” function applications f ( t 1 , .., t n ) ◮ Maximize available info at a single application Usually without partial type application (“all-or-nothing”) f [ T 1 , ..., T m ]( t 1 , ..., t n ) Jenkins, Stump (CS, U. Iowa) Spine-local Type Inference IFL ’18 7 / 33

  18. Our Contributions Type inference for some expressions not typed by other variants of local type inference, by using contextual type-argument inference t ⇑⇓ t ⇑⇓ 1 1 Precise, specificational account of this technique Better support function currying and partial type applications by being “spine-local.” f ( , a ) f ( a , ) Jenkins, Stump (CS, U. Iowa) Spine-local Type Inference IFL ’18 8 / 33

  19. Our Contributions Type inference for some expressions not typed by other variants of local type inference, by using contextual type-argument inference t ⇑⇓ f t ⇑ 1 t ⇑ 2 t ⇓ 3 ⇓ T t ⇑⇓ 1 1 Precise, specificational account of this technique Better support function currying and partial type applications by being “spine-local.” f ( , a ) f ( a , ) Jenkins, Stump (CS, U. Iowa) Spine-local Type Inference IFL ’18 8 / 33

  20. Our Contributions Type inference for some expressions not typed by other variants of local type inference, by using contextual type-argument inference t ⇑⇓ f t ⇑ 1 t ⇓ 2 t ⇓ 3 ⇓ T t ⇑⇓ 1 1 Precise, specificational account of this technique Better support function currying and partial type applications by being “spine-local.” f ( , a ) f ( a , ) Jenkins, Stump (CS, U. Iowa) Spine-local Type Inference IFL ’18 8 / 33

  21. Our Contributions Type inference for some expressions not typed by other variants of local type inference, by using contextual type-argument inference t ⇑⇓ f t ⇑ 1 t ⇓ 2 t ⇓ 3 ⇓ T t ⇑⇓ 1 1 Precise, specificational account of this technique Better support function currying and partial type applications by being “spine-local.” f ( , a ) f [ S , T , V ]( t 1 , t 2 , t 3 ) f ( a , ) Jenkins, Stump (CS, U. Iowa) Spine-local Type Inference IFL ’18 8 / 33

  22. Our Contributions Type inference for some expressions not typed by other variants of local type inference, by using contextual type-argument inference t ⇑⇓ f t ⇑ 1 t ⇓ 2 t ⇓ 3 ⇓ T t ⇑⇓ 1 1 Precise, specificational account of this technique Better support function currying and partial type applications by being “spine-local.” f ( , a ) f [ S ][ T ][ V ] t 1 t 2 t 3 f ( a , ) Jenkins, Stump (CS, U. Iowa) Spine-local Type Inference IFL ’18 8 / 33

  23. Our Contributions Type inference for some expressions not typed by other variants of local type inference, by using contextual type-argument inference t ⇑⇓ f t ⇑ 1 t ⇓ 2 t ⇓ 3 ⇓ T t ⇑⇓ 1 1 Precise, specificational account of this technique Better support function currying and partial type applications by being “spine-local.” f ( , a ) f [ S ][ T ][ V ] t 1 t 2 t 3 f ( a , ) Jenkins, Stump (CS, U. Iowa) Spine-local Type Inference IFL ’18 8 / 33

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend