type inference principal typings and let polymorphism for
play

Type Inference, Principal Typings, and Let-Polymorphism for - PowerPoint PPT Presentation

Type Inference, Principal Typings, and Let-Polymorphism for First-Class Mixin Modules Henning Makholm and Joe Wells Technical University of Denmark and Heriot-Watt University ICFP05 Tallinn, Estonia September 27, 2005 U seful Work


  1. Type Inference, Principal Typings, and Let-Polymorphism for First-Class Mixin Modules Henning Makholm and Joe Wells Technical University of Denmark and Heriot-Watt University ICFP’05 – Tallinn, Estonia – September 27, 2005 U seful Work supported by EU/IST/FET grant 2001-33477 (DART) L ogics, T ypes, R ewriting, and their Type Inference, Principal Typings, and Let-Polymorphism for First-Class Mixin Modules – p.1/17 A utomation

  2. What is this all about? The m-calculus: Variables: x ::= x | y | z | · · · Field labels: ℓ ::= f | g | h | · · · Terms: M, N ::= x | M.ℓ | M ⊕ N | { [ γ 1 ; . . . ; γ k ] } Module items: γ ::= local x = M | export ℓ ⊲ x = M | import ℓ ⊲ x U seful L ogics, T ypes, R ewriting, and their Type Inference, Principal Typings, and Let-Polymorphism for First-Class Mixin Modules – p.2/17 A utomation

  3. What is this all about? The m-calculus: Variables: x ::= x | y | z | · · · Field labels: ℓ ::= f | g | h | · · · Terms: M, N ::= x | M.ℓ | M ⊕ N | { [ γ 1 ; . . . ; γ k ] } Module items: γ ::= local x = M | export ℓ ⊲ x = M | import ℓ ⊲ x We recognize variables, field selection, some kind of fancy sum operator, but what on earth is “ { [ γ 1 , . . . , γ k ] } ”? U seful L ogics, T ypes, R ewriting, and their Type Inference, Principal Typings, and Let-Polymorphism for First-Class Mixin Modules – p.2/17 A utomation

  4. What is this all about? The m-calculus: Variables: x ::= x | y | z | · · · Field labels: ℓ ::= f | g | h | · · · Terms: M, N ::= x | M.ℓ | M ⊕ N | { [ γ 1 ; . . . ; γ k ] } Module items: γ ::= local x = M | export ℓ ⊲ x = M | import ℓ ⊲ x We recognize variables, field selection, some kind of fancy sum operator, but what on earth is “ { [ γ 1 , . . . , γ k ] } ”? Is it a record ...? U seful L ogics, T ypes, R ewriting, and their Type Inference, Principal Typings, and Let-Polymorphism for First-Class Mixin Modules – p.2/17 A utomation

  5. What is this all about? The m-calculus: Variables: x ::= x | y | z | · · · Field labels: ℓ ::= f | g | h | · · · Terms: M, N ::= x | M.ℓ | M ⊕ N | { [ γ 1 ; . . . ; γ k ] } Module items: γ ::= local x = M | export ℓ ⊲ x = M | import ℓ ⊲ x We recognize variables, field selection, some kind of fancy sum operator, but what on earth is “ { [ γ 1 , . . . , γ k ] } ”? Is it a record ...? Is it a letrec ...? U seful L ogics, T ypes, R ewriting, and their Type Inference, Principal Typings, and Let-Polymorphism for First-Class Mixin Modules – p.2/17 A utomation

  6. What is this all about? The m-calculus: Variables: x ::= x | y | z | · · · Field labels: ℓ ::= f | g | h | · · · Terms: M, N ::= x | M.ℓ | M ⊕ N | { [ γ 1 ; . . . ; γ k ] } Module items: γ ::= local x = M | export ℓ ⊲ x = M | import ℓ ⊲ x We recognize variables, field selection, some kind of fancy sum operator, but what on earth is “ { [ γ 1 , . . . , γ k ] } ”? Is it a record ...? Is it a letrec ...? Is it a closure ...? U seful L ogics, T ypes, R ewriting, and their Type Inference, Principal Typings, and Let-Polymorphism for First-Class Mixin Modules – p.2/17 A utomation

  7. What is this all about? The m-calculus: Variables: x ::= x | y | z | · · · Field labels: ℓ ::= f | g | h | · · · Terms: M, N ::= x | M.ℓ | M ⊕ N | { [ γ 1 ; . . . ; γ k ] } Module items: γ ::= local x = M | export ℓ ⊲ x = M | import ℓ ⊲ x We recognize variables, field selection, some kind of fancy sum operator, but what on earth is “ { [ γ 1 , . . . , γ k ] } ”? Is it a record ...? Is it a letrec ...? Is it a closure ...? It is ... SUPERMAN! SUPERMAN! U seful L ogics, T ypes, R ewriting, and their Type Inference, Principal Typings, and Let-Polymorphism for First-Class Mixin Modules – p.2/17 A utomation

  8. What is this all about? The m-calculus: Variables: x ::= x | y | z | · · · Field labels: ℓ ::= f | g | h | · · · Terms: M, N ::= x | M.ℓ | M ⊕ N | { [ γ 1 ; . . . ; γ k ] } Module items: γ ::= local x = M | export ℓ ⊲ x = M | import ℓ ⊲ x We recognize variables, field selection, some kind of fancy sum operator, but what on earth is “ { [ γ 1 , . . . , γ k ] } ”? Is it a record ...? Is it a letrec ...? Is it a closure ...? It is a mixin module ! U seful L ogics, T ypes, R ewriting, and their Type Inference, Principal Typings, and Let-Polymorphism for First-Class Mixin Modules – p.2/17 A utomation

  9. Anatomy of a mixin module The m-calculus: Variables: x ::= x | y | z | · · · Field labels: ℓ ::= f | g | h | · · · Terms: M, N ::= x | M.ℓ | M ⊕ N | { [ γ 1 ; . . . ; γ k ] } Module items: γ ::= local x = M | export ℓ ⊲ x = M | import ℓ ⊲ x A mixin module consists of three kinds of items U seful L ogics, T ypes, R ewriting, and their Type Inference, Principal Typings, and Let-Polymorphism for First-Class Mixin Modules – p.3/17 A utomation

  10. Anatomy of a mixin module The m-calculus: Variables: x ::= x | y | z | · · · Field labels: ℓ ::= f | g | h | · · · Terms: M, N ::= x | M.ℓ | M ⊕ N | { [ γ 1 ; . . . ; γ k ] } Module items: γ ::= local x = M | export ℓ ⊲ x = M | import ℓ ⊲ x A mixin module consists of three kinds of items : A local definition binds an internal name x to an expression M U seful L ogics, T ypes, R ewriting, and their Type Inference, Principal Typings, and Let-Polymorphism for First-Class Mixin Modules – p.3/17 A utomation

  11. Anatomy of a mixin module The m-calculus: Variables: x ::= x | y | z | · · · Field labels: ℓ ::= f | g | h | · · · Terms: M, N ::= x | M.ℓ | M ⊕ N | { [ γ 1 ; . . . ; γ k ] } Module items: γ ::= local x = M | export ℓ ⊲ x = M | import ℓ ⊲ x A mixin module consists of three kinds of items : A local definition binds an internal name x to an expression M An export binds an external label ℓ to an expression M (while also providing a local definition for x ) U seful L ogics, T ypes, R ewriting, and their Type Inference, Principal Typings, and Let-Polymorphism for First-Class Mixin Modules – p.3/17 A utomation

  12. Anatomy of a mixin module The m-calculus: Variables: x ::= x | y | z | · · · Field labels: ℓ ::= f | g | h | · · · Terms: M, N ::= x | M.ℓ | M ⊕ N | { [ γ 1 ; . . . ; γ k ] } Module items: γ ::= local x = M | export ℓ ⊲ x = M | import ℓ ⊲ x A mixin module consists of three kinds of items : A local definition binds an internal name x to an expression M An export binds an external label ℓ to an expression M (while also providing a local definition for x ) An import binds an internal name x to a linking promise represented by the external label ℓ . U seful L ogics, T ypes, R ewriting, and their Type Inference, Principal Typings, and Let-Polymorphism for First-Class Mixin Modules – p.3/17 A utomation

  13. An example { [ local d = λ x . x − 1 ; export odd ⊲ o = λ x . if x = 0 then false else not ( e ( d ( x ))); import even ⊲ e ; ] } ⊕ { [ export even ⊲ v = λ x . if x = 0 then true else not ( p ( x − 1 )); import odd ⊲ p ; ] } U seful L ogics, T ypes, R ewriting, and their Type Inference, Principal Typings, and Let-Polymorphism for First-Class Mixin Modules – p.4/17 A utomation

  14. An example { [ local d = λ x • . x • − 1 ; export odd ⊲ o = λ x • . if x • = 0 then false else not ( e ( d ( x • ))); import even ⊲ e ; ] } ⊕ { [ export even ⊲ v = λ x • . if x • = 0 then true else not ( p ( x • − 1 )); import odd ⊲ p ; ] } U seful L ogics, T ypes, R ewriting, and their Type Inference, Principal Typings, and Let-Polymorphism for First-Class Mixin Modules – p.4/17 A utomation

  15. An example { [ • = λ x • . x • − 1 ; local d • = λ x • . if x • = 0 then false else not ( e ( d • ( x • ))); export odd ⊲ o import even ⊲ e ; ] } ⊕ { [ • = λ x • . if x • = 0 then true else not ( p ( x • − 1 )); export even ⊲ v import odd ⊲ p ; ] } U seful L ogics, T ypes, R ewriting, and their Type Inference, Principal Typings, and Let-Polymorphism for First-Class Mixin Modules – p.4/17 A utomation

  16. An example { [ • = λ x • . x • − 1 ; local d • = λ x • . if x • = 0 then false else not ( e • ( d • ( x • ))); export odd ⊲ o • ; ] } import even ⊲ e ⊕ { [ • = λ x • . if x • = 0 then true else not ( p • ( x • − 1 )); export even ⊲ v • ; ] } import odd ⊲ p U seful L ogics, T ypes, R ewriting, and their Type Inference, Principal Typings, and Let-Polymorphism for First-Class Mixin Modules – p.4/17 A utomation

  17. An example { [ • = λ x • . x • − 1 ; local d • = λ x • . if x • = 0 then false else not ( e • ( d • ( x • ))); export odd ⊲ o • ; ] } import even ⊲ e ⊕ { [ • = λ x • . if x • = 0 then true else not ( p • ( x • − 1 )); export even ⊲ v • ; ] } import odd ⊲ p Linking uses one operand’s exports to bind the other one’s imports U seful L ogics, T ypes, R ewriting, and their Type Inference, Principal Typings, and Let-Polymorphism for First-Class Mixin Modules – p.4/17 A utomation

Recommend


More recommend