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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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