SlideShare a Scribd company logo
1 of 96
Download to read offline
Virtual ECOOP 2022
Direct Foundations for
Compositional Programming
Andong Fan*, Xuejing Huang*,
Han Xu, Yaozhu Sun, and Bruno C. d. S. Oliveira
*equal contributions
Expression Problem
Background
2
Describes the dilemma of modular extension
of datatypes and their operations
e.g. extending simple arithmetic expressions and their operations…
Expression Problem
Background
2
Describes the dilemma of modular extension
of datatypes and their operations
e.g. extending simple arithmetic expressions and their operations…
OOP FP
Expression Problem
Background
2
Describes the dilemma of modular extension
of datatypes and their operations
// class hierarchy
trait Exp {
def eval: Int
}
class Lit(n: Int) extends Exp {
def eval: Int = n
}
class Sub(l: Exp, r: Exp) extends Exp {
def eval: Int = l.eval - r.eval
}
new Sub(new Lit(1), new Lit(2)).eval
e.g. extending simple arithmetic expressions and their operations…
OOP FP
Expression Problem
Background
2
Describes the dilemma of modular extension
of datatypes and their operations
// class hierarchy
trait Exp {
def eval: Int
}
class Lit(n: Int) extends Exp {
def eval: Int = n
}
class Sub(l: Exp, r: Exp) extends Exp {
def eval: Int = l.eval - r.eval
}
new Sub(new Lit(1), new Lit(2)).eval
// algebraic datatype
sealed trait Exp
case class Lit(n: Int) extends Exp
case class Sub(l: Exp, r: Exp) extends Exp
// pattern matching function
def eval(exp: Exp): Int = exp match {
case Lit(n) => n
case Sub(l, r) => eval(l) - eval(r)
}
eval(Sub(Lit(1), Lit(2)))
e.g. extending simple arithmetic expressions and their operations…
OOP FP
Expression Problem
3
of datatypes and their operations
// class hierarchy
trait Exp {
def eval: Int
}
class Lit(n: Int) extends Exp {
def eval: Int = n
}
class Sub(l: Exp, r: Exp) extends Exp {
def eval: Int = l.eval - r.eval
}
class Add(l: Exp, r: Exp) extends Exp {
def eval: Int = l.eval + r.eval
}
new Sub(new Lit(1), new Lit(2)).eval
Modular!
OOP FP
Describes the dilemma of modular extension
e.g. extending simple arithmetic expressions and their operations…
// algebraic datatype
sealed trait Exp
case class Lit(n: Int) extends Exp
case class Sub(l: Exp, r: Exp) extends Exp
// pattern matching function
def eval(exp: Exp): Int = exp match {
case Lit(n) => n
case Sub(l, r) => eval(l) - eval(r)
}
eval(Sub(Lit(1), Lit(2)))
Background
Expression Problem
4
of datatypes and their operations
trait Exp {
def eval: Int
def print: String
}
class Lit(n: Int) extends Exp {
def eval: Int = n
def print: String = ..
}
class Sub(l: Exp, r: Exp) extends Exp {
def eval: Int = l.eval - r.eval
def print: String = ..
}
class Add(l: Exp, r: Exp) extends Exp {
def eval: Int = l.eval + r.eval
def print: String = ..
}
new Sub(new Lit(1), new Lit(2)).eval
OOP FP
Non-Modular!
Non-Modular!
Non-Modular!
Non-Modular!
Describes the dilemma of modular extension
e.g. extending simple arithmetic expressions and their operations…
// algebraic datatype
sealed trait Exp
case class Lit(n: Int) extends Exp
case class Sub(l: Exp, r: Exp) extends Exp
// pattern matching function
def eval(exp: Exp): Int = exp match {
case Lit(n) => n
case Sub(l, r) => eval(l) - eval(r)
}
eval(Sub(Lit(1), Lit(2)))
Background
Expression Problem
4
of datatypes and their operations
trait Exp {
def eval: Int
def print: String
}
class Lit(n: Int) extends Exp {
def eval: Int = n
def print: String = ..
}
class Sub(l: Exp, r: Exp) extends Exp {
def eval: Int = l.eval - r.eval
def print: String = ..
}
class Add(l: Exp, r: Exp) extends Exp {
def eval: Int = l.eval + r.eval
def print: String = ..
}
new Sub(new Lit(1), new Lit(2)).eval
OOP FP
Non-Modular!
Non-Modular!
Non-Modular!
Non-Modular!
Modular extension of


Datatypes ✅


Operations ❌
Describes the dilemma of modular extension
e.g. extending simple arithmetic expressions and their operations…
// algebraic datatype
sealed trait Exp
case class Lit(n: Int) extends Exp
case class Sub(l: Exp, r: Exp) extends Exp
// pattern matching function
def eval(exp: Exp): Int = exp match {
case Lit(n) => n
case Sub(l, r) => eval(l) - eval(r)
}
eval(Sub(Lit(1), Lit(2)))
Background
Expression Problem
5
of datatypes and their operations
trait Exp {
def eval: Int
def print: String
}
class Lit(n: Int) extends Exp {
def eval: Int = n
def print: String = ..
}
class Sub(l: Exp, r: Exp) extends Exp {
def eval: Int = l.eval - r.eval
def print: String = ..
}
class Add(l: Exp, r: Exp) extends Exp {
def eval: Int = l.eval + r.eval
def print: String = ..
}
new Sub(new Lit(1), new Lit(2)).eval
// algebraic datatype
sealed trait Exp
case class Lit(n: Int) extends Exp
case class Sub(l: Exp, r: Exp) extends Exp
// pattern matching function
def eval(exp: Exp): Int = exp match {
case Lit(n) => n
case Sub(l, r) => eval(l) - eval(r)
}
def print(exp: Exp): String = exp match {
case Lit(n) => ..
case Sub(l, r) => ..
}
eval(Sub(Lit(1), Lit(2)))
OOP FP
Non-Modular!
Non-Modular!
Non-Modular!
Non-Modular!
Modular extension of


Datatypes ✅


Operations ❌
Describes the dilemma of modular extension
Modular!
e.g. extending simple arithmetic expressions and their operations…
Background
Expression Problem
6
of datatypes and their operations
trait Exp {
def eval: Int
def print: String
}
class Lit(n: Int) extends Exp {
def eval: Int = n
def print: String = ..
}
class Sub(l: Exp, r: Exp) extends Exp {
def eval: Int = l.eval - r.eval
def print: String = ..
}
class Add(l: Exp, r: Exp) extends Exp {
def eval: Int = l.eval + r.eval
def print: String = ..
}
new Sub(new Lit(1), new Lit(2)).eval
sealed trait Exp
case class Lit(n: Int) extends Exp
case class Sub(l: Exp, r: Exp) extends Exp
case class Add(l: Exp, r: Exp) extends Exp
// pattern matching function
def eval(exp: Exp): Int = exp match {
case Lit(n) => n
case Sub(l, r) => eval(l) - eval(r)
case Add(l, r) => ..
}
def print(exp: Exp): String = exp match {
case Lit(n) => ..
case Sub(l, r) => ..
case Add(l, r) => ..
}
eval(Sub(Lit(1), Lit(2)))
OOP FP
Non-Modular!
Non-Modular!
Non-Modular!
Non-Modular!
Modular extension of


Datatypes ✅


Operations ❌
Describes the dilemma of modular extension
Non-Modular!
Non-Modular!
Non-Modular!
e.g. extending simple arithmetic expressions and their operations…
Background
Expression Problem
6
of datatypes and their operations
trait Exp {
def eval: Int
def print: String
}
class Lit(n: Int) extends Exp {
def eval: Int = n
def print: String = ..
}
class Sub(l: Exp, r: Exp) extends Exp {
def eval: Int = l.eval - r.eval
def print: String = ..
}
class Add(l: Exp, r: Exp) extends Exp {
def eval: Int = l.eval + r.eval
def print: String = ..
}
new Sub(new Lit(1), new Lit(2)).eval
sealed trait Exp
case class Lit(n: Int) extends Exp
case class Sub(l: Exp, r: Exp) extends Exp
case class Add(l: Exp, r: Exp) extends Exp
// pattern matching function
def eval(exp: Exp): Int = exp match {
case Lit(n) => n
case Sub(l, r) => eval(l) - eval(r)
case Add(l, r) => ..
}
def print(exp: Exp): String = exp match {
case Lit(n) => ..
case Sub(l, r) => ..
case Add(l, r) => ..
}
eval(Sub(Lit(1), Lit(2)))
OOP FP
Non-Modular!
Non-Modular!
Non-Modular!
Non-Modular!
Modular extension of


Datatypes ✅


Operations ❌
Describes the dilemma of modular extension
Non-Modular!
Non-Modular!
Non-Modular!
Modular extension of


Datatypes ❌


Operations ✅
e.g. extending simple arithmetic expressions and their operations…
Background
Compositional Programming*
7
Background
Provides natural solutions to the Expression Problem
Employs intersection types, a merge operator, and
fi
rst-class traits
Novel programming paradigm featuring modularity
*Weixin Zhang, Yaozhu Sun, and Bruno C. d. S. Oliveira. Compositional programming.

ACM Transactions on Programming Languages and Systems (TOPLAS), 43(3):1–61, 2021.
Compositional Programming
8
• Intersection types
• Merge operator
• First-class traits
Background
Novel programming paradigm featuring modularity
Compositional Programming
8
• Intersection types
• Merge operator
• First-class traits
Compose types with &
Background
Novel programming paradigm featuring modularity
Compositional Programming
8
• Intersection types
• Merge operator
• First-class traits
Compose types with &
e.g. {a : A} & {b : B} == {a : A ; b : B}
Background
Novel programming paradigm featuring modularity
Compositional Programming
8
• Intersection types
• Merge operator
• First-class traits
Compose types with &
e.g. {a : A} & {b : B} == {a : A ; b : B}
Compose terms with ,,
Introductory structure of intersection types
Background
Novel programming paradigm featuring modularity
Compositional Programming
8
• Intersection types
• Merge operator
• First-class traits
Compose types with &
e.g. {a : A} & {b : B} == {a : A ; b : B}
Compose terms with ,,
Introductory structure of intersection types
e.g. 1 ,, true has type Int & Bool
Background
Novel programming paradigm featuring modularity
Compositional Programming
8
• Intersection types
• Merge operator
• First-class traits
Compose types with &
e.g. {a : A} & {b : B} == {a : A ; b : B}
Compose terms with ,,
Introductory structure of intersection types
e.g. 1 ,, true has type Int & Bool
Basic structures of Composition Programming
Background
Novel programming paradigm featuring modularity
The CP Language
9
type NumSig<Exp> = {
Lit: Int -> Exp;
Add: Exp -> Exp -> Exp;
};
Background
Note: In CP the merge operator is `,` while it’s originally `,,`
The CP Language
9
evalNum = trait implements NumSig<Eval> => {
(Lit n).eval = n;
(Add e1 e2).eval = e1.eval + e2.eval;
};
type NumSig<Exp> = {
Lit: Int -> Exp;
Add: Exp -> Exp -> Exp;
};
type Eval = { eval: Int };
Background
Note: In CP the merge operator is `,` while it’s originally `,,`
The CP Language
9
evalNum = trait implements NumSig<Eval> => {
(Lit n).eval = n;
(Add e1 e2).eval = e1.eval + e2.eval;
};
type NumSig<Exp> = {
Lit: Int -> Exp;
Add: Exp -> Exp -> Exp;
};
type Print = { print: String };
type Eval = { eval: Int };
Background
printNum = trait implements NumSig<Print> => {
(Lit n).print = toString n;
(Add e1 e2).print = e1.print ++ "+" ++
e2.print;
};
Note: In CP the merge operator is `,` while it’s originally `,,`
The CP Language
9
evalNum = trait implements NumSig<Eval> => {
(Lit n).eval = n;
(Add e1 e2).eval = e1.eval + e2.eval;
};
exp = new (repoNum @(Eval & Print) , evalNum , printNum);
repoNum Exp = trait [self: NumSig<Exp>] => {
num = Add (Lit 2) (Lit 3);
};
type NumSig<Exp> = {
Lit: Int -> Exp;
Add: Exp -> Exp -> Exp;
};
type Print = { print: String };
type Eval = { eval: Int };
Background
printNum = trait implements NumSig<Print> => {
(Lit n).print = toString n;
(Add e1 e2).print = e1.print ++ "+" ++
e2.print;
};
Note: In CP the merge operator is `,` while it’s originally `,,`
The CP Language
9
evalNum = trait implements NumSig<Eval> => {
(Lit n).eval = n;
(Add e1 e2).eval = e1.eval + e2.eval;
};
exp = new (repoNum @(Eval & Print) , evalNum , printNum);
repoNum Exp = trait [self: NumSig<Exp>] => {
num = Add (Lit 2) (Lit 3);
}; Merge operator
type NumSig<Exp> = {
Lit: Int -> Exp;
Add: Exp -> Exp -> Exp;
};
type Print = { print: String };
type Eval = { eval: Int };
Background
printNum = trait implements NumSig<Print> => {
(Lit n).print = toString n;
(Add e1 e2).print = e1.print ++ "+" ++
e2.print;
};
Note: In CP the merge operator is `,` while it’s originally `,,`
The CP Language
9
evalNum = trait implements NumSig<Eval> => {
(Lit n).eval = n;
(Add e1 e2).eval = e1.eval + e2.eval;
};
exp = new (repoNum @(Eval & Print) , evalNum , printNum);
repoNum Exp = trait [self: NumSig<Exp>] => {
num = Add (Lit 2) (Lit 3);
};
Intersection type argument
Merge operator
type NumSig<Exp> = {
Lit: Int -> Exp;
Add: Exp -> Exp -> Exp;
};
type Print = { print: String };
type Eval = { eval: Int };
Background
printNum = trait implements NumSig<Print> => {
(Lit n).print = toString n;
(Add e1 e2).print = e1.print ++ "+" ++
e2.print;
};
Note: In CP the merge operator is `,` while it’s originally `,,`
The CP Language
9
evalNum = trait implements NumSig<Eval> => {
(Lit n).eval = n;
(Add e1 e2).eval = e1.eval + e2.eval;
};
exp = new (repoNum @(Eval & Print) , evalNum , printNum);
repoNum Exp = trait [self: NumSig<Exp>] => {
num = Add (Lit 2) (Lit 3);
};
Intersection type argument
Merge operator
type NumSig<Exp> = {
Lit: Int -> Exp;
Add: Exp -> Exp -> Exp;
};
type Print = { print: String };
type Eval = { eval: Int };
exp.num.eval —> 5
exp.num.print —> “2+3”
Background
printNum = trait implements NumSig<Print> => {
(Lit n).print = toString n;
(Add e1 e2).print = e1.print ++ "+" ++
e2.print;
};
Note: In CP the merge operator is `,` while it’s originally `,,`
evalNum = trait implements NumSig<Eval> => {
(Lit n).eval = n;
(Add e1 e2).eval = e1.eval + e2.eval;
};
printNum = trait implements NumSig<Print> => {
(Lit n).print = toString n;
(Add e1 e2).print = e1.print ++ "+" ++
e2.print;
};
type NumSig<Exp> = {
Lit: Int -> Exp;
Add: Exp -> Exp -> Exp;
};
type Print = { print: String };
type Eval = { eval: Int };
type MulSig<Exp> = {
Mul: Exp -> Exp -> Exp;
};
Background
The CP Language
10
Note: In CP the merge operator is `,` while it’s originally `,,`
evalNum = trait implements NumSig<Eval> => {
(Lit n).eval = n;
(Add e1 e2).eval = e1.eval + e2.eval;
};
printNum = trait implements NumSig<Print> => {
(Lit n).print = toString n;
(Add e1 e2).print = e1.print ++ "+" ++
e2.print;
};
type NumSig<Exp> = {
Lit: Int -> Exp;
Add: Exp -> Exp -> Exp;
};
type Print = { print: String };
type Eval = { eval: Int };
type MulSig<Exp> = {
Mul: Exp -> Exp -> Exp;
};
type ExpSig<Exp> =
NumSig<Exp> & MulSig<Exp>;
Background
Intersection type
The CP Language
10
Note: In CP the merge operator is `,` while it’s originally `,,`
evalNum = trait implements NumSig<Eval> => {
(Lit n).eval = n;
(Add e1 e2).eval = e1.eval + e2.eval;
};
printNum = trait implements NumSig<Print> => {
(Lit n).print = toString n;
(Add e1 e2).print = e1.print ++ "+" ++
e2.print;
};
type NumSig<Exp> = {
Lit: Int -> Exp;
Add: Exp -> Exp -> Exp;
};
type Print = { print: String };
type Eval = { eval: Int };
type MulSig<Exp> = {
Mul: Exp -> Exp -> Exp;
}; evalMul = trait implements MulSig<Eval> => {
(Mul e1 e2).eval = e1.eval * e2.eval;
};
type ExpSig<Exp> =
NumSig<Exp> & MulSig<Exp>;
Background
Intersection type
The CP Language
10
Note: In CP the merge operator is `,` while it’s originally `,,`
evalNum = trait implements NumSig<Eval> => {
(Lit n).eval = n;
(Add e1 e2).eval = e1.eval + e2.eval;
};
printNum = trait implements NumSig<Print> => {
(Lit n).print = toString n;
(Add e1 e2).print = e1.print ++ "+" ++
e2.print;
};
type NumSig<Exp> = {
Lit: Int -> Exp;
Add: Exp -> Exp -> Exp;
};
type Print = { print: String };
type Eval = { eval: Int };
type MulSig<Exp> = {
Mul: Exp -> Exp -> Exp;
}; evalMul = trait implements MulSig<Eval> => {
(Mul e1 e2).eval = e1.eval * e2.eval;
};
printMul = trait implements MulSig<Print> => {
(Mul e1 e2).print = e1.print ++ "*" ++ e2.print;
};
type ExpSig<Exp> =
NumSig<Exp> & MulSig<Exp>;
Background
Intersection type
The CP Language
10
Note: In CP the merge operator is `,` while it’s originally `,,`
evalNum = trait implements NumSig<Eval> => {
(Lit n).eval = n;
(Add e1 e2).eval = e1.eval + e2.eval;
};
printNum = trait implements NumSig<Print> => {
(Lit n).print = toString n;
(Add e1 e2).print = e1.print ++ "+" ++
e2.print;
};
type NumSig<Exp> = {
Lit: Int -> Exp;
Add: Exp -> Exp -> Exp;
};
type Print = { print: String };
type Eval = { eval: Int };
type MulSig<Exp> = {
Mul: Exp -> Exp -> Exp;
}; evalMul = trait implements MulSig<Eval> => {
(Mul e1 e2).eval = e1.eval * e2.eval;
};
printMul = trait implements MulSig<Print> => {
(Mul e1 e2).print = e1.print ++ "*" ++ e2.print;
};
type ExpSig<Exp> =
NumSig<Exp> & MulSig<Exp>;
repoExp Exp = trait [self: ExpSig<Exp>] => {
mul = Mul (Lit 2) (Lit 3)
};
Background
Intersection type
The CP Language
10
Note: In CP the merge operator is `,` while it’s originally `,,`
evalNum = trait implements NumSig<Eval> => {
(Lit n).eval = n;
(Add e1 e2).eval = e1.eval + e2.eval;
};
printNum = trait implements NumSig<Print> => {
(Lit n).print = toString n;
(Add e1 e2).print = e1.print ++ "+" ++
e2.print;
};
type NumSig<Exp> = {
Lit: Int -> Exp;
Add: Exp -> Exp -> Exp;
};
type Print = { print: String };
type Eval = { eval: Int };
type MulSig<Exp> = {
Mul: Exp -> Exp -> Exp;
}; evalMul = trait implements MulSig<Eval> => {
(Mul e1 e2).eval = e1.eval * e2.eval;
};
printMul = trait implements MulSig<Print> => {
(Mul e1 e2).print = e1.print ++ "*" ++ e2.print;
};
type ExpSig<Exp> =
NumSig<Exp> & MulSig<Exp>;
repoExp Exp = trait [self: ExpSig<Exp>] => {
mul = Mul (Lit 2) (Lit 3)
};
exp' = new (repoExp @(Eval & Print) ,
evalNum , evalMul , printNum , printMul);
Background
Intersection type
Merge operator
The CP Language
10
Note: In CP the merge operator is `,` while it’s originally `,,`
evalNum = trait implements NumSig<Eval> => {
(Lit n).eval = n;
(Add e1 e2).eval = e1.eval + e2.eval;
};
printNum = trait implements NumSig<Print> => {
(Lit n).print = toString n;
(Add e1 e2).print = e1.print ++ "+" ++
e2.print;
};
type NumSig<Exp> = {
Lit: Int -> Exp;
Add: Exp -> Exp -> Exp;
};
type Print = { print: String };
type Eval = { eval: Int };
type MulSig<Exp> = {
Mul: Exp -> Exp -> Exp;
}; evalMul = trait implements MulSig<Eval> => {
(Mul e1 e2).eval = e1.eval * e2.eval;
};
printMul = trait implements MulSig<Print> => {
(Mul e1 e2).print = e1.print ++ "*" ++ e2.print;
};
type ExpSig<Exp> =
NumSig<Exp> & MulSig<Exp>;
repoExp Exp = trait [self: ExpSig<Exp>] => {
mul = Mul (Lit 2) (Lit 3)
};
exp' = new (repoExp @(Eval & Print) ,
evalNum , evalMul , printNum , printMul);
exp'.num.eval —> 6
exp'.num.print —> “2*3”
Background
Intersection type
Merge operator
The CP Language
10
Note: In CP the merge operator is `,` while it’s originally `,,`
evalNum = trait implements NumSig<Eval> => {
(Lit n).eval = n;
(Add e1 e2).eval = e1.eval + e2.eval;
};
printNum = trait implements NumSig<Print> => {
(Lit n).print = toString n;
(Add e1 e2).print = e1.print ++ "+" ++
e2.print;
};
type NumSig<Exp> = {
Lit: Int -> Exp;
Add: Exp -> Exp -> Exp;
};
type Print = { print: String };
type Eval = { eval: Int };
type MulSig<Exp> = {
Mul: Exp -> Exp -> Exp;
}; evalMul = trait implements MulSig<Eval> => {
(Mul e1 e2).eval = e1.eval * e2.eval;
};
printMul = trait implements MulSig<Print> => {
(Mul e1 e2).print = e1.print ++ "*" ++ e2.print;
};
type ExpSig<Exp> =
NumSig<Exp> & MulSig<Exp>;
repoExp Exp = trait [self: ExpSig<Exp>] => {
mul = Mul (Lit 2) (Lit 3)
};
exp' = new (repoExp @(Eval & Print) ,
evalNum , evalMul , printNum , printMul);
exp'.num.eval —> 6
exp'.num.print —> “2*3”
Background
Intersection type
Merge operator
The CP Language
10
Note: In CP the merge operator is `,` while it’s originally `,,`
repoExp
+ mul
Lit
+ eval
evalNum
Add
+ eval
printNum
Lit
+ print
Add
+ print
evalMul
Mul
+ eval
printMul
Mul
+ print
, , , ,
=
Lit
+ eval
+ print
exp
Mul
+ eval
+ print
Add
+ eval
+ print
+ mul
evalNum = trait implements NumSig<Eval> => {
(Lit n).eval = n;
(Add e1 e2).eval = e1.eval + e2.eval;
};
printNum = trait implements NumSig<Print> => {
(Lit n).print = toString n;
(Add e1 e2).print = e1.print ++ "+" ++
e2.print;
};
type NumSig<Exp> = {
Lit: Int -> Exp;
Add: Exp -> Exp -> Exp;
};
type Print = { print: String };
type Eval = { eval: Int };
type MulSig<Exp> = {
Mul: Exp -> Exp -> Exp;
}; evalMul = trait implements MulSig<Eval> => {
(Mul e1 e2).eval = e1.eval * e2.eval;
};
printMul = trait implements MulSig<Print> => {
(Mul e1 e2).print = e1.print ++ "*" ++ e2.print;
};
type ExpSig<Exp> =
NumSig<Exp> & MulSig<Exp>;
repoExp Exp = trait [self: ExpSig<Exp>] => {
mul = Mul (Lit 2) (Lit 3)
};
exp' = new (repoExp @(Eval & Print) ,
evalNum , evalMul , printNum , printMul);
exp'.num.eval —> 6
exp'.num.print —> “2*3”
Background
Intersection type
Merge operator
The CP Language
10
Note: In CP the merge operator is `,` while it’s originally `,,`
Solves the EP
Modular Dependency Injection
Modular Context Evolution
Disjoint Intersection Types*
Background
11
Languages with the merge operator may be ambiguous
*Bruno C. d. S. Oliveira, Zhiyuan Shi, and João Alpuim. Disjoint intersection types.

In International Conference on Functional Programming (ICFP), 2016.
Disjoint Intersection Types*
Background
11
Languages with the merge operator may be ambiguous
1 ,, 2 has type Int & Int
(1 , , 2) + 3 ⟶ ???
*Bruno C. d. S. Oliveira, Zhiyuan Shi, and João Alpuim. Disjoint intersection types.

In International Conference on Functional Programming (ICFP), 2016.
Disjoint Intersection Types*
Background
11
Languages with the merge operator may be ambiguous
1 ,, 2 has type Int & Int
(1 , , 2) + 3 ⟶ ???
Oliveira et al. proposed disjoint intersection types
Reject ambiguous merges with overlapping types
*Bruno C. d. S. Oliveira, Zhiyuan Shi, and João Alpuim. Disjoint intersection types.

In International Conference on Functional Programming (ICFP), 2016.
Disjoint Intersection Types*
Background
11
Languages with the merge operator may be ambiguous
1 ,, 2 has type Int & Int
(1 , , 2) + 3 ⟶ ???
Oliveira et al. proposed disjoint intersection types
Reject ambiguous merges with overlapping types
Type is disjoint to type (i.e. )
A B A * B ≐
For all type if and then
C A <: C B <: C C ∼
𝖳
𝗈
𝗉
*Bruno C. d. S. Oliveira, Zhiyuan Shi, and João Alpuim. Disjoint intersection types.

In International Conference on Functional Programming (ICFP), 2016.
Disjoint Intersection Types*
Background
11
Languages with the merge operator may be ambiguous
1 ,, 2 has type Int & Int
(1 , , 2) + 3 ⟶ ???
Oliveira et al. proposed disjoint intersection types
Reject ambiguous merges with overlapping types
Type is disjoint to type (i.e. )
A B A * B ≐
For all type if and then
C A <: C B <: C C ∼
𝖳
𝗈
𝗉
Type equivalence
*Bruno C. d. S. Oliveira, Zhiyuan Shi, and João Alpuim. Disjoint intersection types.

In International Conference on Functional Programming (ICFP), 2016.
Disjoint Intersection Types*
Background
11
Languages with the merge operator may be ambiguous
1 ,, 2 has type Int & Int
(1 , , 2) + 3 ⟶ ???
Oliveira et al. proposed disjoint intersection types
Reject ambiguous merges with overlapping types
Type is disjoint to type (i.e. )
A B A * B ≐
For all type if and then
C A <: C B <: C C ∼
𝖳
𝗈
𝗉
Type equivalence
Int is the common supertype of Int itself
*Bruno C. d. S. Oliveira, Zhiyuan Shi, and João Alpuim. Disjoint intersection types.

In International Conference on Functional Programming (ICFP), 2016.
Disjoint Intersection Types*
Background
11
Languages with the merge operator may be ambiguous
1 ,, 2 has type Int & Int
(1 , , 2) + 3 ⟶ ???
Oliveira et al. proposed disjoint intersection types
Reject ambiguous merges with overlapping types
Type is disjoint to type (i.e. )
A B A * B ≐
For all type if and then
C A <: C B <: C C ∼
𝖳
𝗈
𝗉
Type equivalence
Int is the common supertype of Int itself
Int * Int, therefore 1 ,, 2 is rejected
*Bruno C. d. S. Oliveira, Zhiyuan Shi, and João Alpuim. Disjoint intersection types.

In International Conference on Functional Programming (ICFP), 2016.
12
Motivation
The Calculus - CP’s Foundation
𝖥
+
i
A polymorphic calculus with disjoint intersection types and a merge operator
13
Motivation
The Calculus - CP’s Foundation
𝖥
+
i
A polymorphic calculus with disjoint intersection types and a merge operator
13
Motivation
The Calculus - CP’s Foundation
𝖥
+
i
A polymorphic calculus with disjoint intersection types and a merge operator
The current formulation of
𝖥
+
i
based on an elaboration semantics
13
Motivation
The Calculus - CP’s Foundation
𝖥
+
i
A polymorphic calculus with disjoint intersection types and a merge operator
The current formulation of
𝖥
+
i
• Lack of impredicative polymorphism
• Lack of recursion
its coherence proof causes…
based on an elaboration semantics
13
Motivation
The Calculus - CP’s Foundation
𝖥
+
i
A polymorphic calculus with disjoint intersection types and a merge operator
The current formulation of
𝖥
+
i
• Lack of impredicative polymorphism
• Lack of recursion
While CP allows the creation of

objects with polymorphic methods
its coherence proof causes…
based on an elaboration semantics
14
Motivation
The Calculus - CP’s Foundation
𝖥
+
i
The current formulation of
𝖥
+
i
• Lack of impredicative polymorphism
• Lack of recursion
its coherence proof causes…
based on an elaboration semantics While CP’s elaboration of traits…
↝
A polymorphic calculus with disjoint intersection types and a merge operator
15
Motivation
The Calculus - CP’s Foundation
𝖥
+
i
The current formulation of
𝖥
+
i
its coherence proof causes…
based on an elaboration semantics While CP’s elaboration of traits…
↝
A polymorphic calculus with disjoint intersection types and a merge operator
• Lack of impredicative polymorphism
• Lack of recursion
16
Motivation
The Calculus - CP’s Foundation
𝖥
+
i
The current formulation of
𝖥
+
i
• Di
ff
erence in evaluation strategies
its coherence proof causes…
based on an elaboration semantics
While call-by-value will diverge in…
• CP assumed call-by-name
• is call-by-value
𝖥
+
i
A polymorphic calculus with disjoint intersection types and a merge operator
Note: CP is implemented as call-by-need
• Lack of impredicative polymorphism
• Lack of recursion
17
Motivation
The Calculus - CP’s Foundation
𝖥
+
i
The current formulation of
𝖥
+
i
• Di
ff
erence in evaluation strategies
its coherence proof causes…
based on an elaboration semantics
• CP assumed call-by-name
• is call-by-value
𝖥
+
i
}The gap between theory & practice
A polymorphic calculus with disjoint intersection types and a merge operator
Note: CP is implemented as call-by-need
• Lack of impredicative polymorphism
• Lack of recursion
18
Our Contribution
The Calculus - CP’s Foundation
𝖥
+
i
The new formulation of
𝖥
+
i
its determinism proof is simple
based on a direct Type-Directed Operational Semantics*
• CP assumed call-by-name
• is call-by-name
𝖥
+
i
}The gap between theory & practice
• Lack of impredicative polymorphism
• Lack of recursion
• Di
ff
erence in evaluation strategies
A polymorphic calculus with disjoint intersection types and a merge operator
Note: CP is implemented as call-by-need
*Xuejing Huang and Bruno C. d. S. Oliveira. A type-directed operational semantics for a calculus with a merge operator.

In 34th European Conference on Object-Oriented Programming (ECOOP 2020),

volume 166 of Leibniz International Proceedings in Informatics (LIPIcs), pages 26:1–26:32.
18
Our Contribution
The Calculus - CP’s Foundation
𝖥
+
i
The new formulation of
𝖥
+
i
its determinism proof is simple
based on a direct Type-Directed Operational Semantics*
• CP assumed call-by-name
• is call-by-name
𝖥
+
i
}The gap between theory & practice
• Lack of impredicative polymorphism
• Lack of recursion
• Di
ff
erence in evaluation strategies
A polymorphic calculus with disjoint intersection types and a merge operator
Note: CP is implemented as call-by-need
*Xuejing Huang and Bruno C. d. S. Oliveira. A type-directed operational semantics for a calculus with a merge operator.

In 34th European Conference on Object-Oriented Programming (ECOOP 2020),

volume 166 of Leibniz International Proceedings in Informatics (LIPIcs), pages 26:1–26:32.
18
Our Contribution
The Calculus - CP’s Foundation
𝖥
+
i
The new formulation of
𝖥
+
i
its determinism proof is simple
based on a direct Type-Directed Operational Semantics*
• CP assumed call-by-name
• is call-by-name
𝖥
+
i
}The gap between theory & practice
• Lack of impredicative polymorphism
• Lack of recursion
• Di
ff
erence in evaluation strategies
A polymorphic calculus with disjoint intersection types and a merge operator
Note: CP is implemented as call-by-need
*Xuejing Huang and Bruno C. d. S. Oliveira. A type-directed operational semantics for a calculus with a merge operator.

In 34th European Conference on Object-Oriented Programming (ECOOP 2020),

volume 166 of Leibniz International Proceedings in Informatics (LIPIcs), pages 26:1–26:32.
18
Our Contribution
The Calculus - CP’s Foundation
𝖥
+
i
The new formulation of
𝖥
+
i
its determinism proof is simple
based on a direct Type-Directed Operational Semantics*
• CP assumed call-by-name
• is call-by-name
𝖥
+
i
}The gap between theory & practice
• Lack of impredicative polymorphism
• Lack of recursion
• Di
ff
erence in evaluation strategies
A polymorphic calculus with disjoint intersection types and a merge operator
Note: CP is implemented as call-by-need
*Xuejing Huang and Bruno C. d. S. Oliveira. A type-directed operational semantics for a calculus with a merge operator.

In 34th European Conference on Object-Oriented Programming (ECOOP 2020),

volume 166 of Leibniz International Proceedings in Informatics (LIPIcs), pages 26:1–26:32.
18
Our Contribution
The Calculus - CP’s Foundation
𝖥
+
i
The new formulation of
𝖥
+
i
its determinism proof is simple
based on a direct Type-Directed Operational Semantics*
• CP assumed call-by-name
• is call-by-name
𝖥
+
i
}The gap between theory & practice
• Lack of impredicative polymorphism
• Lack of recursion
• Di
ff
erence in evaluation strategies
A polymorphic calculus with disjoint intersection types and a merge operator
Note: CP is implemented as call-by-need
*Xuejing Huang and Bruno C. d. S. Oliveira. A type-directed operational semantics for a calculus with a merge operator.

In 34th European Conference on Object-Oriented Programming (ECOOP 2020),

volume 166 of Leibniz International Proceedings in Informatics (LIPIcs), pages 26:1–26:32.
The Calculus
𝖥
+
i
Example
19
type LitSig<Exp> = { Lit: Int -> Exp };
type Eval = { eval: Int };
type Print = { print: String };
evalLit = trait implements LigSig<Eval> => {
(Lit n).eval = n;
}
printLit = trait implements LigSig<Print> => {
(Lit n).print = toString n;
}
repoLit Exp = trait [self: LitSig<Exp>] => {
num = Lit ((1+1) , true);
};
(new repoLit @(Eval & Print) , evalLit , printLit).num
The Calculus
𝖥
+
i
Example
19
type LitSig<Exp> = { Lit: Int -> Exp };
type Eval = { eval: Int };
type Print = { print: String };
evalLit = trait implements LigSig<Eval> => {
(Lit n).eval = n;
}
printLit = trait implements LigSig<Print> => {
(Lit n).print = toString n;
}
repoLit Exp = trait [self: LitSig<Exp>] => {
num = Lit ((1+1) , true);
};
(new repoLit @(Eval & Print) , evalLit , printLit).num
The Calculus
𝖥
+
i
Example
19
type LitSig<Exp> = { Lit: Int -> Exp };
type Eval = { eval: Int };
type Print = { print: String };
evalLit = trait implements LigSig<Eval> => {
(Lit n).eval = n;
}
printLit = trait implements LigSig<Print> => {
(Lit n).print = toString n;
}
repoLit Exp = trait [self: LitSig<Exp>] => {
num = Lit ((1+1) , true);
};
(new repoLit @(Eval & Print) , evalLit , printLit).num
({
𝖫
𝗂
𝗍
= f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
}} , , {
𝖫
𝗂
𝗍
= g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
}}) .
𝖫
𝗂
𝗍
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
)
↝
after simpli
fi
cation
The Calculus
𝖥
+
i
Example
19
type LitSig<Exp> = { Lit: Int -> Exp };
type Eval = { eval: Int };
type Print = { print: String };
evalLit = trait implements LigSig<Eval> => {
(Lit n).eval = n;
}
printLit = trait implements LigSig<Print> => {
(Lit n).print = toString n;
}
repoLit Exp = trait [self: LitSig<Exp>] => {
num = Lit ((1+1) , true);
};
(new repoLit @(Eval & Print) , evalLit , printLit).num
({
𝖫
𝗂
𝗍
= f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
}} , , {
𝖫
𝗂
𝗍
= g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
}}) .
𝖫
𝗂
𝗍
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
)
↝
after simpli
fi
cation
g := (λx :
𝖨
𝗇
𝗍
. {
𝗉
𝗋
𝗂
𝗇
𝗍
=
𝗍
𝗈
𝖲
𝗍
𝗋
𝗂
𝗇
𝗀
x})
f := (λx :
𝖨
𝗇
𝗍
. {
𝖾
𝗏
𝖺
𝗅
= x})
The Calculus
𝖥
+
i
Example
19
type LitSig<Exp> = { Lit: Int -> Exp };
type Eval = { eval: Int };
type Print = { print: String };
evalLit = trait implements LigSig<Eval> => {
(Lit n).eval = n;
}
printLit = trait implements LigSig<Print> => {
(Lit n).print = toString n;
}
repoLit Exp = trait [self: LitSig<Exp>] => {
num = Lit ((1+1) , true);
};
(new repoLit @(Eval & Print) , evalLit , printLit).num
({
𝖫
𝗂
𝗍
= f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
}} , , {
𝖫
𝗂
𝗍
= g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
}}) .
𝖫
𝗂
𝗍
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
)
↝
after simpli
fi
cation
g := (λx :
𝖨
𝗇
𝗍
. {
𝗉
𝗋
𝗂
𝗇
𝗍
=
𝗍
𝗈
𝖲
𝗍
𝗋
𝗂
𝗇
𝗀
x})
f := (λx :
𝖨
𝗇
𝗍
. {
𝖾
𝗏
𝖺
𝗅
= x})
The Calculus
𝖥
+
i
Example
19
type LitSig<Exp> = { Lit: Int -> Exp };
type Eval = { eval: Int };
type Print = { print: String };
evalLit = trait implements LigSig<Eval> => {
(Lit n).eval = n;
}
printLit = trait implements LigSig<Print> => {
(Lit n).print = toString n;
}
repoLit Exp = trait [self: LitSig<Exp>] => {
num = Lit ((1+1) , true);
};
(new repoLit @(Eval & Print) , evalLit , printLit).num
({
𝖫
𝗂
𝗍
= f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
}} , , {
𝖫
𝗂
𝗍
= g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
}}) .
𝖫
𝗂
𝗍
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
)
↝
after simpli
fi
cation
↪
(f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} , , g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
}) ((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
)
g := (λx :
𝖨
𝗇
𝗍
. {
𝗉
𝗋
𝗂
𝗇
𝗍
=
𝗍
𝗈
𝖲
𝗍
𝗋
𝗂
𝗇
𝗀
x})
f := (λx :
𝖨
𝗇
𝗍
. {
𝖾
𝗏
𝖺
𝗅
= x})
The Calculus
𝖥
+
i
20
Example Dynamic
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
)
(f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} , , g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
})
g := (λx :
𝖨
𝗇
𝗍
. {
𝗉
𝗋
𝗂
𝗇
𝗍
=
𝗍
𝗈
𝖲
𝗍
𝗋
𝗂
𝗇
𝗀
x})
f := (λx :
𝖨
𝗇
𝗍
. {
𝖾
𝗏
𝖺
𝗅
= x})
The Calculus
𝖥
+
i
20
Example Dynamic
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
)
↪ Parallel application
(f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} , , g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
})
g := (λx :
𝖨
𝗇
𝗍
. {
𝗉
𝗋
𝗂
𝗇
𝗍
=
𝗍
𝗈
𝖲
𝗍
𝗋
𝗂
𝗇
𝗀
x})
f := (λx :
𝖨
𝗇
𝗍
. {
𝖾
𝗏
𝖺
𝗅
= x})
The Calculus
𝖥
+
i
20
Example Dynamic
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
)
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
)
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
)
↪ Parallel application
(f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} , , g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
})
g := (λx :
𝖨
𝗇
𝗍
. {
𝗉
𝗋
𝗂
𝗇
𝗍
=
𝗍
𝗈
𝖲
𝗍
𝗋
𝗂
𝗇
𝗀
x})
f := (λx :
𝖨
𝗇
𝗍
. {
𝖾
𝗏
𝖺
𝗅
= x})
The Calculus
𝖥
+
i
20
Example Dynamic
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
)
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
)
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
)
:
𝖨
𝗇
𝗍
:
𝖨
𝗇
𝗍
↪ Parallel application
(f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} , , g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
})
g := (λx :
𝖨
𝗇
𝗍
. {
𝗉
𝗋
𝗂
𝗇
𝗍
=
𝗍
𝗈
𝖲
𝗍
𝗋
𝗂
𝗇
𝗀
x})
f := (λx :
𝖨
𝗇
𝗍
. {
𝖾
𝗏
𝖺
𝗅
= x})
The Calculus
𝖥
+
i
20
Example Dynamic
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
)
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
)
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
)
:
𝖨
𝗇
𝗍
:
𝖨
𝗇
𝗍
Call-by-name
↪ Parallel application
(f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} , , g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
})
g := (λx :
𝖨
𝗇
𝗍
. {
𝗉
𝗋
𝗂
𝗇
𝗍
=
𝗍
𝗈
𝖲
𝗍
𝗋
𝗂
𝗇
𝗀
x})
f := (λx :
𝖨
𝗇
𝗍
. {
𝖾
𝗏
𝖺
𝗅
= x})
{
𝖾
𝗏
𝖺
𝗅
= ((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) :
𝖨
𝗇
𝗍
} , , {
𝗉
𝗋
𝗂
𝗇
𝗍
=
𝗍
𝗈
𝖲
𝗍
𝗋
𝗂
𝗇
𝗀
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) :
𝖨
𝗇
𝗍
} Value!
The Calculus
𝖥
+
i
20
Example Dynamic
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
)
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
)
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
)
:
𝖨
𝗇
𝗍
:
𝖨
𝗇
𝗍
Call-by-name
↪ Parallel application
(f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} , , g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
})
g := (λx :
𝖨
𝗇
𝗍
. {
𝗉
𝗋
𝗂
𝗇
𝗍
=
𝗍
𝗈
𝖲
𝗍
𝗋
𝗂
𝗇
𝗀
x})
f := (λx :
𝖨
𝗇
𝗍
. {
𝖾
𝗏
𝖺
𝗅
= x})
{
𝖾
𝗏
𝖺
𝗅
= ((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) :
𝖨
𝗇
𝗍
} , , {
𝗉
𝗋
𝗂
𝗇
𝗍
=
𝗍
𝗈
𝖲
𝗍
𝗋
𝗂
𝗇
𝗀
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) :
𝖨
𝗇
𝗍
}
Consider projecting out…
𝖾
𝗏
𝖺
𝗅
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) :
𝖨
𝗇
𝗍
Value!
The Calculus
𝖥
+
i
20
Example Dynamic
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
)
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
)
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
)
:
𝖨
𝗇
𝗍
:
𝖨
𝗇
𝗍
Call-by-name
↪ Parallel application
↪ Evaluate the merge
Evaluate the merge
(f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} , , g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
})
g := (λx :
𝖨
𝗇
𝗍
. {
𝗉
𝗋
𝗂
𝗇
𝗍
=
𝗍
𝗈
𝖲
𝗍
𝗋
𝗂
𝗇
𝗀
x})
f := (λx :
𝖨
𝗇
𝗍
. {
𝖾
𝗏
𝖺
𝗅
= x})
{
𝖾
𝗏
𝖺
𝗅
= ((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) :
𝖨
𝗇
𝗍
} , , {
𝗉
𝗋
𝗂
𝗇
𝗍
=
𝗍
𝗈
𝖲
𝗍
𝗋
𝗂
𝗇
𝗀
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) :
𝖨
𝗇
𝗍
}
Consider projecting out…
𝖾
𝗏
𝖺
𝗅
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) :
𝖨
𝗇
𝗍
Value!
The Calculus
𝖥
+
i
20
Example Dynamic
(2 , ,
𝗍
𝗋
𝗎
𝖾
) :
𝖨
𝗇
𝗍
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
)
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
)
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
)
:
𝖨
𝗇
𝗍
:
𝖨
𝗇
𝗍
Call-by-name
↪ Parallel application
↪ Evaluate the merge
Evaluate the merge Lazy evaluation
(f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} , , g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
})
g := (λx :
𝖨
𝗇
𝗍
. {
𝗉
𝗋
𝗂
𝗇
𝗍
=
𝗍
𝗈
𝖲
𝗍
𝗋
𝗂
𝗇
𝗀
x})
f := (λx :
𝖨
𝗇
𝗍
. {
𝖾
𝗏
𝖺
𝗅
= x})
{
𝖾
𝗏
𝖺
𝗅
= ((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) :
𝖨
𝗇
𝗍
} , , {
𝗉
𝗋
𝗂
𝗇
𝗍
=
𝗍
𝗈
𝖲
𝗍
𝗋
𝗂
𝗇
𝗀
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) :
𝖨
𝗇
𝗍
}
Consider projecting out…
𝖾
𝗏
𝖺
𝗅
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) :
𝖨
𝗇
𝗍
Value!
The Calculus
𝖥
+
i
20
Example Dynamic
(2 , ,
𝗍
𝗋
𝗎
𝖾
) :
𝖨
𝗇
𝗍
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
)
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
)
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
)
:
𝖨
𝗇
𝗍
:
𝖨
𝗇
𝗍
Call-by-name
↪ Parallel application
↪ Evaluate the merge
Evaluate the merge Lazy evaluation
↪ Casting
(f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} , , g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
})
g := (λx :
𝖨
𝗇
𝗍
. {
𝗉
𝗋
𝗂
𝗇
𝗍
=
𝗍
𝗈
𝖲
𝗍
𝗋
𝗂
𝗇
𝗀
x})
f := (λx :
𝖨
𝗇
𝗍
. {
𝖾
𝗏
𝖺
𝗅
= x})
{
𝖾
𝗏
𝖺
𝗅
= ((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) :
𝖨
𝗇
𝗍
} , , {
𝗉
𝗋
𝗂
𝗇
𝗍
=
𝗍
𝗈
𝖲
𝗍
𝗋
𝗂
𝗇
𝗀
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) :
𝖨
𝗇
𝗍
}
Consider projecting out…
𝖾
𝗏
𝖺
𝗅
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) :
𝖨
𝗇
𝗍
Value!
The Calculus
𝖥
+
i
20
Example Dynamic
(2 , ,
𝗍
𝗋
𝗎
𝖾
) :
𝖨
𝗇
𝗍
2
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
)
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
)
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
)
:
𝖨
𝗇
𝗍
:
𝖨
𝗇
𝗍
Call-by-name
↪ Parallel application
↪ Evaluate the merge
Evaluate the merge Lazy evaluation
↪ Casting Select the desired value with type annotations
(f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} , , g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
})
g := (λx :
𝖨
𝗇
𝗍
. {
𝗉
𝗋
𝗂
𝗇
𝗍
=
𝗍
𝗈
𝖲
𝗍
𝗋
𝗂
𝗇
𝗀
x})
f := (λx :
𝖨
𝗇
𝗍
. {
𝖾
𝗏
𝖺
𝗅
= x})
{
𝖾
𝗏
𝖺
𝗅
= ((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) :
𝖨
𝗇
𝗍
} , , {
𝗉
𝗋
𝗂
𝗇
𝗍
=
𝗍
𝗈
𝖲
𝗍
𝗋
𝗂
𝗇
𝗀
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) :
𝖨
𝗇
𝗍
}
Consider projecting out…
𝖾
𝗏
𝖺
𝗅
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) :
𝖨
𝗇
𝗍
Value!
The Calculus
𝖥
+
i
Example
21
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) ⇒
(f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} , , g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
})
g := (λx :
𝖨
𝗇
𝗍
. {
𝗉
𝗋
𝗂
𝗇
𝗍
=
𝗍
𝗈
𝖲
𝗍
𝗋
𝗂
𝗇
𝗀
x})
f := (λx :
𝖨
𝗇
𝗍
. {
𝖾
𝗏
𝖺
𝗅
= x})
Static
The Calculus
𝖥
+
i
Example
21
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) ⇒
Type synthesis
(f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} , , g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
})
g := (λx :
𝖨
𝗇
𝗍
. {
𝗉
𝗋
𝗂
𝗇
𝗍
=
𝗍
𝗈
𝖲
𝗍
𝗋
𝗂
𝗇
𝗀
x})
f := (λx :
𝖨
𝗇
𝗍
. {
𝖾
𝗏
𝖺
𝗅
= x})
Static
The Calculus
𝖥
+
i
Example
21
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) ⇒
(f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} , , g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
}) ⇒
Type synthesis
(f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} , , g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
})
g := (λx :
𝖨
𝗇
𝗍
. {
𝗉
𝗋
𝗂
𝗇
𝗍
=
𝗍
𝗈
𝖲
𝗍
𝗋
𝗂
𝗇
𝗀
x})
f := (λx :
𝖨
𝗇
𝗍
. {
𝖾
𝗏
𝖺
𝗅
= x})
Static
The Calculus
𝖥
+
i
Example
21
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) ⇒
(f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} , , g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
}) ⇒
Type synthesis
(f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} , , g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
})
g := (λx :
𝖨
𝗇
𝗍
. {
𝗉
𝗋
𝗂
𝗇
𝗍
=
𝗍
𝗈
𝖲
𝗍
𝗋
𝗂
𝗇
𝗀
x})
f := (λx :
𝖨
𝗇
𝗍
. {
𝖾
𝗏
𝖺
𝗅
= x})
Static
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) ⇐
The Calculus
𝖥
+
i
Example
21
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) ⇒
(f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} , , g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
}) ⇒
Type synthesis
(f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} , , g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
})
g := (λx :
𝖨
𝗇
𝗍
. {
𝗉
𝗋
𝗂
𝗇
𝗍
=
𝗍
𝗈
𝖲
𝗍
𝗋
𝗂
𝗇
𝗀
x})
f := (λx :
𝖨
𝗇
𝗍
. {
𝖾
𝗏
𝖺
𝗅
= x})
Static
Type checking
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) ⇐
The Calculus
𝖥
+
i
Example
21
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) ⇒
(f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} , , g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
}) ⇒
(f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} , , g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
})
g := (λx :
𝖨
𝗇
𝗍
. {
𝗉
𝗋
𝗂
𝗇
𝗍
=
𝗍
𝗈
𝖲
𝗍
𝗋
𝗂
𝗇
𝗀
x})
f := (λx :
𝖨
𝗇
𝗍
. {
𝖾
𝗏
𝖺
𝗅
= x})
Static
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) ⇐
The Calculus
𝖥
+
i
Example
21
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) ⇒
(f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} , , g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
}) ⇒
f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} ⇒ g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
}⇒
(f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} , , g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
})
g := (λx :
𝖨
𝗇
𝗍
. {
𝗉
𝗋
𝗂
𝗇
𝗍
=
𝗍
𝗈
𝖲
𝗍
𝗋
𝗂
𝗇
𝗀
x})
f := (λx :
𝖨
𝗇
𝗍
. {
𝖾
𝗏
𝖺
𝗅
= x})
Static
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) ⇐
The Calculus
𝖥
+
i
Example
21
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) ⇒
(f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} , , g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
}) ⇒
f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} ⇒ g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
}⇒
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
}
(f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} , , g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
})
g := (λx :
𝖨
𝗇
𝗍
. {
𝗉
𝗋
𝗂
𝗇
𝗍
=
𝗍
𝗈
𝖲
𝗍
𝗋
𝗂
𝗇
𝗀
x})
f := (λx :
𝖨
𝗇
𝗍
. {
𝖾
𝗏
𝖺
𝗅
= x})
Static
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) ⇐
The Calculus
𝖥
+
i
Example
21
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) ⇒
(f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} , , g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
}) ⇒
f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} ⇒ g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
}⇒
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
}
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
}
(f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} , , g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
})
g := (λx :
𝖨
𝗇
𝗍
. {
𝗉
𝗋
𝗂
𝗇
𝗍
=
𝗍
𝗈
𝖲
𝗍
𝗋
𝗂
𝗇
𝗀
x})
f := (λx :
𝖨
𝗇
𝗍
. {
𝖾
𝗏
𝖺
𝗅
= x})
Static
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) ⇐
The Calculus
𝖥
+
i
Example
21
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) ⇒
(f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} , , g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
}) ⇒
f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} ⇒ g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
}⇒
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
}
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
}
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
}
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
}
*
(f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} , , g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
})
g := (λx :
𝖨
𝗇
𝗍
. {
𝗉
𝗋
𝗂
𝗇
𝗍
=
𝗍
𝗈
𝖲
𝗍
𝗋
𝗂
𝗇
𝗀
x})
f := (λx :
𝖨
𝗇
𝗍
. {
𝖾
𝗏
𝖺
𝗅
= x})
Static
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) ⇐
The Calculus
𝖥
+
i
Example
21
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) ⇒
(f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} , , g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
}) ⇒
f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} ⇒ g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
}⇒
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
}
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
}
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
}
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
}
*
(
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
}) (
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
})
&
(f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} , , g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
})
g := (λx :
𝖨
𝗇
𝗍
. {
𝗉
𝗋
𝗂
𝗇
𝗍
=
𝗍
𝗈
𝖲
𝗍
𝗋
𝗂
𝗇
𝗀
x})
f := (λx :
𝖨
𝗇
𝗍
. {
𝖾
𝗏
𝖺
𝗅
= x})
Static
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) ⇐
The Calculus
𝖥
+
i
Example
22
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) ⇒
(f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} , , g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
}) ⇒(
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
}) (
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
})
&
(f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} , , g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
})
g := (λx :
𝖨
𝗇
𝗍
. {
𝗉
𝗋
𝗂
𝗇
𝗍
=
𝗍
𝗈
𝖲
𝗍
𝗋
𝗂
𝗇
𝗀
x})
f := (λx :
𝖨
𝗇
𝗍
. {
𝖾
𝗏
𝖺
𝗅
= x})
Static
⊳
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} & {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
}
(
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
}) (
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
})
&
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) ⇐
The Calculus
𝖥
+
i
Example
22
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) ⇒
(f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} , , g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
}) ⇒(
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
}) (
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
})
&
(f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} , , g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
})
g := (λx :
𝖨
𝗇
𝗍
. {
𝗉
𝗋
𝗂
𝗇
𝗍
=
𝗍
𝗈
𝖲
𝗍
𝗋
𝗂
𝗇
𝗀
x})
f := (λx :
𝖨
𝗇
𝗍
. {
𝖾
𝗏
𝖺
𝗅
= x})
Static
⊳
Applicative distribution
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} & {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
}
(
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
}) (
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
})
&
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) ⇐
The Calculus
𝖥
+
i
Example
22
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) ⇒
(f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} , , g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
}) ⇒(
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
}) (
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
})
&
(f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} , , g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
})
g := (λx :
𝖨
𝗇
𝗍
. {
𝗉
𝗋
𝗂
𝗇
𝗍
=
𝗍
𝗈
𝖲
𝗍
𝗋
𝗂
𝗇
𝗀
x})
f := (λx :
𝖨
𝗇
𝗍
. {
𝖾
𝗏
𝖺
𝗅
= x})
Static
⊳
Applicative distribution
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} & {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
}
(
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
}) (
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
})
&
(A → B1) & (A → B2) <: A → B1 & B2
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) ⇐
The Calculus
𝖥
+
i
Example
23
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) ⇒
(f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} , , g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
}) ⇒(
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
}) (
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
})
&
(f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} , , g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
})
g := (λx :
𝖨
𝗇
𝗍
. {
𝗉
𝗋
𝗂
𝗇
𝗍
=
𝗍
𝗈
𝖲
𝗍
𝗋
𝗂
𝗇
𝗀
x})
f := (λx :
𝖨
𝗇
𝗍
. {
𝖾
𝗏
𝖺
𝗅
= x})
Static
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) ⇐
⊳
Applicative distribution
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} & {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
}
(
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
}) (
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
})
&
(A → B1) & (A → B2) <: A → B1 & B2
𝖨
𝗇
𝗍
The Calculus
𝖥
+
i
Example
23
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) ⇒
(f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} , , g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
}) ⇒(
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
}) (
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
})
&
(f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} , , g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
})
g := (λx :
𝖨
𝗇
𝗍
. {
𝗉
𝗋
𝗂
𝗇
𝗍
=
𝗍
𝗈
𝖲
𝗍
𝗋
𝗂
𝗇
𝗀
x})
f := (λx :
𝖨
𝗇
𝗍
. {
𝖾
𝗏
𝖺
𝗅
= x})
Static
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) ⇐
⊳
Applicative distribution
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} & {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
}
(
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
}) (
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
})
&
(A → B1) & (A → B2) <: A → B1 & B2
𝖨
𝗇
𝗍
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) ⇒
The Calculus
𝖥
+
i
Example
23
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) ⇒
(f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} , , g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
}) ⇒(
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
}) (
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
})
&
(f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} , , g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
})
g := (λx :
𝖨
𝗇
𝗍
. {
𝗉
𝗋
𝗂
𝗇
𝗍
=
𝗍
𝗈
𝖲
𝗍
𝗋
𝗂
𝗇
𝗀
x})
f := (λx :
𝖨
𝗇
𝗍
. {
𝖾
𝗏
𝖺
𝗅
= x})
Static
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) ⇐
⊳
Applicative distribution
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} & {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
}
(
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
}) (
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
})
&
(A → B1) & (A → B2) <: A → B1 & B2
𝖨
𝗇
𝗍
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) ⇒
𝖨
𝗇
𝗍
&
𝖡
𝗈
𝗈
𝗅
The Calculus
𝖥
+
i
Example
23
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) ⇒
(f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} , , g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
}) ⇒(
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
}) (
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
})
&
(f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} , , g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
})
g := (λx :
𝖨
𝗇
𝗍
. {
𝗉
𝗋
𝗂
𝗇
𝗍
=
𝗍
𝗈
𝖲
𝗍
𝗋
𝗂
𝗇
𝗀
x})
f := (λx :
𝖨
𝗇
𝗍
. {
𝖾
𝗏
𝖺
𝗅
= x})
Static
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) ⇐
⊳
Applicative distribution
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} & {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
}
(
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
}) (
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
})
&
(A → B1) & (A → B2) <: A → B1 & B2
𝖨
𝗇
𝗍
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) ⇒
𝖨
𝗇
𝗍
&
𝖡
𝗈
𝗈
𝗅
𝖨
𝗇
𝗍
&
𝖡
𝗈
𝗈
𝗅
<:
𝖨
𝗇
𝗍
The Calculus
𝖥
+
i
Example
23
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) ⇒
(f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} , , g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
}) ⇒(
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
}) (
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
})
&
(f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} , , g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
})
g := (λx :
𝖨
𝗇
𝗍
. {
𝗉
𝗋
𝗂
𝗇
𝗍
=
𝗍
𝗈
𝖲
𝗍
𝗋
𝗂
𝗇
𝗀
x})
f := (λx :
𝖨
𝗇
𝗍
. {
𝖾
𝗏
𝖺
𝗅
= x})
Static
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) ⇐
⊳
Applicative distribution
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} & {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
}
(
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
}) (
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
})
&
(A → B1) & (A → B2) <: A → B1 & B2
𝖨
𝗇
𝗍
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) ⇒
𝖨
𝗇
𝗍
&
𝖡
𝗈
𝗈
𝗅
𝖨
𝗇
𝗍
&
𝖡
𝗈
𝗈
𝗅
<:
𝖨
𝗇
𝗍
The Calculus
𝖥
+
i
Example
23
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) ⇒
(f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} , , g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
}) ⇒(
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
}) (
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
})
&
(f :
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} , , g :
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
})
g := (λx :
𝖨
𝗇
𝗍
. {
𝗉
𝗋
𝗂
𝗇
𝗍
=
𝗍
𝗈
𝖲
𝗍
𝗋
𝗂
𝗇
𝗀
x})
f := (λx :
𝖨
𝗇
𝗍
. {
𝖾
𝗏
𝖺
𝗅
= x})
Static
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) ⇐
⊳
Applicative distribution
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} & {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
}
(
𝖨
𝗇
𝗍
→ {
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
}) (
𝖨
𝗇
𝗍
→ {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
})
&
(A → B1) & (A → B2) <: A → B1 & B2
𝖨
𝗇
𝗍
((1 + 1) , ,
𝗍
𝗋
𝗎
𝖾
) ⇒
𝖨
𝗇
𝗍
&
𝖡
𝗈
𝗈
𝗅
𝖨
𝗇
𝗍
&
𝖡
𝗈
𝗈
𝗅
<:
𝖨
𝗇
𝗍
{
𝖾
𝗏
𝖺
𝗅
:
𝖨
𝗇
𝗍
} & {
𝗉
𝗋
𝗂
𝗇
𝗍
:
𝖲
𝗍
𝗋
}
Thanks!
More in the paper…
24
• Artifact
• Algorithmic subtyping with polymorphic types
• Enhanced subtyping and disjointness
• More CP examples
• Self-contained presentation of
𝖥
+
i
Thanks!
More in the paper…
25
• Artifact
• Algorithmic subtyping with polymorphic types
• Enhanced subtyping and disjointness
• More CP examples
• Self-contained presentation of
𝖥
+
i
*Xuejing Huang, Jinxu Zhao, and Bruno C. d. S. Oliveira.

Taming the merge operator. Journal of Functional Programming, 31:e28, 2021.
Thanks!
More in the paper…
25
• Artifact
• Algorithmic subtyping with polymorphic types
Based on splittable types*
• Enhanced subtyping and disjointness
• More CP examples
• Self-contained presentation of
𝖥
+
i
*Xuejing Huang, Jinxu Zhao, and Bruno C. d. S. Oliveira.

Taming the merge operator. Journal of Functional Programming, 31:e28, 2021.
Thanks!
More in the paper…
25
• Artifact
• Algorithmic subtyping with polymorphic types
Based on splittable types*
• Enhanced subtyping and disjointness
More types equivalent to Top
• More CP examples
• Self-contained presentation of
𝖥
+
i
*Xuejing Huang, Jinxu Zhao, and Bruno C. d. S. Oliveira.

Taming the merge operator. Journal of Functional Programming, 31:e28, 2021.
Thanks!
More in the paper…
25
• Artifact
is type sound, formalized in the Coq theorem prover
𝖥
+
i
• Algorithmic subtyping with polymorphic types
Based on splittable types*
• Enhanced subtyping and disjointness
More types equivalent to Top
• More CP examples
• Self-contained presentation of
𝖥
+
i
A PureScript implementation of CP on top of
𝖥
+
i
*Xuejing Huang, Jinxu Zhao, and Bruno C. d. S. Oliveira.

Taming the merge operator. Journal of Functional Programming, 31:e28, 2021.

More Related Content

Similar to ecoop-slides.pdf

Under the hood of scala implicits (Scala eXchange 2014)
Under the hood of scala implicits (Scala eXchange 2014)Under the hood of scala implicits (Scala eXchange 2014)
Under the hood of scala implicits (Scala eXchange 2014)Alexander Podkhalyuzin
 
Introduction to Functional Programming with Scala
Introduction to Functional Programming with ScalaIntroduction to Functional Programming with Scala
Introduction to Functional Programming with Scalapramode_ce
 
LISP: Introduction To Lisp
LISP: Introduction To LispLISP: Introduction To Lisp
LISP: Introduction To LispLISP Content
 
Principles of functional progrmming in scala
Principles of functional progrmming in scalaPrinciples of functional progrmming in scala
Principles of functional progrmming in scalaehsoon
 
Under the hood of scala implicits (kl10tch 10.03.2015)
Under the hood of scala implicits (kl10tch 10.03.2015)Under the hood of scala implicits (kl10tch 10.03.2015)
Under the hood of scala implicits (kl10tch 10.03.2015)Alexander Podkhalyuzin
 
All About ... Functions
All About ... FunctionsAll About ... Functions
All About ... FunctionsMichal Bigos
 
Phyton Learning extracts
Phyton Learning extracts Phyton Learning extracts
Phyton Learning extracts Pavan Babu .G
 
Testing for share
Testing for share Testing for share
Testing for share Rajeev Mehta
 
Morel, a data-parallel programming language
Morel, a data-parallel programming languageMorel, a data-parallel programming language
Morel, a data-parallel programming languageJulian Hyde
 
Morel, a Functional Query Language
Morel, a Functional Query LanguageMorel, a Functional Query Language
Morel, a Functional Query LanguageJulian Hyde
 
Scala as a Declarative Language
Scala as a Declarative LanguageScala as a Declarative Language
Scala as a Declarative Languagevsssuresh
 
Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Martin Odersky
 
Functional Programming by Examples using Haskell
Functional Programming by Examples using HaskellFunctional Programming by Examples using Haskell
Functional Programming by Examples using Haskellgoncharenko
 

Similar to ecoop-slides.pdf (20)

Frp2016 3
Frp2016 3Frp2016 3
Frp2016 3
 
Under the hood of scala implicits (Scala eXchange 2014)
Under the hood of scala implicits (Scala eXchange 2014)Under the hood of scala implicits (Scala eXchange 2014)
Under the hood of scala implicits (Scala eXchange 2014)
 
Introduction to Functional Programming with Scala
Introduction to Functional Programming with ScalaIntroduction to Functional Programming with Scala
Introduction to Functional Programming with Scala
 
LISP: Introduction to lisp
LISP: Introduction to lispLISP: Introduction to lisp
LISP: Introduction to lisp
 
LISP: Introduction To Lisp
LISP: Introduction To LispLISP: Introduction To Lisp
LISP: Introduction To Lisp
 
Principles of functional progrmming in scala
Principles of functional progrmming in scalaPrinciples of functional progrmming in scala
Principles of functional progrmming in scala
 
Under the hood of scala implicits (kl10tch 10.03.2015)
Under the hood of scala implicits (kl10tch 10.03.2015)Under the hood of scala implicits (kl10tch 10.03.2015)
Under the hood of scala implicits (kl10tch 10.03.2015)
 
CPPDS Slide.pdf
CPPDS Slide.pdfCPPDS Slide.pdf
CPPDS Slide.pdf
 
Scala Paradigms
Scala ParadigmsScala Paradigms
Scala Paradigms
 
All About ... Functions
All About ... FunctionsAll About ... Functions
All About ... Functions
 
Phyton Learning extracts
Phyton Learning extracts Phyton Learning extracts
Phyton Learning extracts
 
Testing for share
Testing for share Testing for share
Testing for share
 
Morel, a data-parallel programming language
Morel, a data-parallel programming languageMorel, a data-parallel programming language
Morel, a data-parallel programming language
 
Morel, a Functional Query Language
Morel, a Functional Query LanguageMorel, a Functional Query Language
Morel, a Functional Query Language
 
Special topics in finance lecture 2
Special topics in finance   lecture 2Special topics in finance   lecture 2
Special topics in finance lecture 2
 
Scala as a Declarative Language
Scala as a Declarative LanguageScala as a Declarative Language
Scala as a Declarative Language
 
Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009
 
Functional Programming by Examples using Haskell
Functional Programming by Examples using HaskellFunctional Programming by Examples using Haskell
Functional Programming by Examples using Haskell
 
Scala Bootcamp 1
Scala Bootcamp 1Scala Bootcamp 1
Scala Bootcamp 1
 
Introducing scala
Introducing scalaIntroducing scala
Introducing scala
 

Recently uploaded

Unlocking the Potential: Deep dive into ocean of Ceramic Magnets.pptx
Unlocking  the Potential: Deep dive into ocean of Ceramic Magnets.pptxUnlocking  the Potential: Deep dive into ocean of Ceramic Magnets.pptx
Unlocking the Potential: Deep dive into ocean of Ceramic Magnets.pptxanandsmhk
 
A relative description on Sonoporation.pdf
A relative description on Sonoporation.pdfA relative description on Sonoporation.pdf
A relative description on Sonoporation.pdfnehabiju2046
 
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...anilsa9823
 
Behavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdfBehavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdfSELF-EXPLANATORY
 
Is RISC-V ready for HPC workload? Maybe?
Is RISC-V ready for HPC workload? Maybe?Is RISC-V ready for HPC workload? Maybe?
Is RISC-V ready for HPC workload? Maybe?Patrick Diehl
 
Orientation, design and principles of polyhouse
Orientation, design and principles of polyhouseOrientation, design and principles of polyhouse
Orientation, design and principles of polyhousejana861314
 
Physiochemical properties of nanomaterials and its nanotoxicity.pptx
Physiochemical properties of nanomaterials and its nanotoxicity.pptxPhysiochemical properties of nanomaterials and its nanotoxicity.pptx
Physiochemical properties of nanomaterials and its nanotoxicity.pptxAArockiyaNisha
 
Bentham & Hooker's Classification. along with the merits and demerits of the ...
Bentham & Hooker's Classification. along with the merits and demerits of the ...Bentham & Hooker's Classification. along with the merits and demerits of the ...
Bentham & Hooker's Classification. along with the merits and demerits of the ...Nistarini College, Purulia (W.B) India
 
Disentangling the origin of chemical differences using GHOST
Disentangling the origin of chemical differences using GHOSTDisentangling the origin of chemical differences using GHOST
Disentangling the origin of chemical differences using GHOSTSérgio Sacani
 
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43bNightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43bSérgio Sacani
 
Boyles law module in the grade 10 science
Boyles law module in the grade 10 scienceBoyles law module in the grade 10 science
Boyles law module in the grade 10 sciencefloriejanemacaya1
 
SOLUBLE PATTERN RECOGNITION RECEPTORS.pptx
SOLUBLE PATTERN RECOGNITION RECEPTORS.pptxSOLUBLE PATTERN RECOGNITION RECEPTORS.pptx
SOLUBLE PATTERN RECOGNITION RECEPTORS.pptxkessiyaTpeter
 
Call Girls in Munirka Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
Call Girls in Munirka Delhi 💯Call Us 🔝9953322196🔝 💯Escort.Call Girls in Munirka Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
Call Girls in Munirka Delhi 💯Call Us 🔝9953322196🔝 💯Escort.aasikanpl
 
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...Sérgio Sacani
 
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |aasikanpl
 
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...Sérgio Sacani
 
G9 Science Q4- Week 1-2 Projectile Motion.ppt
G9 Science Q4- Week 1-2 Projectile Motion.pptG9 Science Q4- Week 1-2 Projectile Motion.ppt
G9 Science Q4- Week 1-2 Projectile Motion.pptMAESTRELLAMesa2
 
Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )aarthirajkumar25
 
Analytical Profile of Coleus Forskohlii | Forskolin .pdf
Analytical Profile of Coleus Forskohlii | Forskolin .pdfAnalytical Profile of Coleus Forskohlii | Forskolin .pdf
Analytical Profile of Coleus Forskohlii | Forskolin .pdfSwapnil Therkar
 

Recently uploaded (20)

Unlocking the Potential: Deep dive into ocean of Ceramic Magnets.pptx
Unlocking  the Potential: Deep dive into ocean of Ceramic Magnets.pptxUnlocking  the Potential: Deep dive into ocean of Ceramic Magnets.pptx
Unlocking the Potential: Deep dive into ocean of Ceramic Magnets.pptx
 
A relative description on Sonoporation.pdf
A relative description on Sonoporation.pdfA relative description on Sonoporation.pdf
A relative description on Sonoporation.pdf
 
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...
 
Behavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdfBehavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdf
 
Is RISC-V ready for HPC workload? Maybe?
Is RISC-V ready for HPC workload? Maybe?Is RISC-V ready for HPC workload? Maybe?
Is RISC-V ready for HPC workload? Maybe?
 
Orientation, design and principles of polyhouse
Orientation, design and principles of polyhouseOrientation, design and principles of polyhouse
Orientation, design and principles of polyhouse
 
Physiochemical properties of nanomaterials and its nanotoxicity.pptx
Physiochemical properties of nanomaterials and its nanotoxicity.pptxPhysiochemical properties of nanomaterials and its nanotoxicity.pptx
Physiochemical properties of nanomaterials and its nanotoxicity.pptx
 
Bentham & Hooker's Classification. along with the merits and demerits of the ...
Bentham & Hooker's Classification. along with the merits and demerits of the ...Bentham & Hooker's Classification. along with the merits and demerits of the ...
Bentham & Hooker's Classification. along with the merits and demerits of the ...
 
Disentangling the origin of chemical differences using GHOST
Disentangling the origin of chemical differences using GHOSTDisentangling the origin of chemical differences using GHOST
Disentangling the origin of chemical differences using GHOST
 
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43bNightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
 
The Philosophy of Science
The Philosophy of ScienceThe Philosophy of Science
The Philosophy of Science
 
Boyles law module in the grade 10 science
Boyles law module in the grade 10 scienceBoyles law module in the grade 10 science
Boyles law module in the grade 10 science
 
SOLUBLE PATTERN RECOGNITION RECEPTORS.pptx
SOLUBLE PATTERN RECOGNITION RECEPTORS.pptxSOLUBLE PATTERN RECOGNITION RECEPTORS.pptx
SOLUBLE PATTERN RECOGNITION RECEPTORS.pptx
 
Call Girls in Munirka Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
Call Girls in Munirka Delhi 💯Call Us 🔝9953322196🔝 💯Escort.Call Girls in Munirka Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
Call Girls in Munirka Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
 
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
 
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |
 
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
 
G9 Science Q4- Week 1-2 Projectile Motion.ppt
G9 Science Q4- Week 1-2 Projectile Motion.pptG9 Science Q4- Week 1-2 Projectile Motion.ppt
G9 Science Q4- Week 1-2 Projectile Motion.ppt
 
Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )
 
Analytical Profile of Coleus Forskohlii | Forskolin .pdf
Analytical Profile of Coleus Forskohlii | Forskolin .pdfAnalytical Profile of Coleus Forskohlii | Forskolin .pdf
Analytical Profile of Coleus Forskohlii | Forskolin .pdf
 

ecoop-slides.pdf

  • 1. Virtual ECOOP 2022 Direct Foundations for Compositional Programming Andong Fan*, Xuejing Huang*, Han Xu, Yaozhu Sun, and Bruno C. d. S. Oliveira *equal contributions
  • 2. Expression Problem Background 2 Describes the dilemma of modular extension of datatypes and their operations e.g. extending simple arithmetic expressions and their operations…
  • 3. Expression Problem Background 2 Describes the dilemma of modular extension of datatypes and their operations e.g. extending simple arithmetic expressions and their operations… OOP FP
  • 4. Expression Problem Background 2 Describes the dilemma of modular extension of datatypes and their operations // class hierarchy trait Exp { def eval: Int } class Lit(n: Int) extends Exp { def eval: Int = n } class Sub(l: Exp, r: Exp) extends Exp { def eval: Int = l.eval - r.eval } new Sub(new Lit(1), new Lit(2)).eval e.g. extending simple arithmetic expressions and their operations… OOP FP
  • 5. Expression Problem Background 2 Describes the dilemma of modular extension of datatypes and their operations // class hierarchy trait Exp { def eval: Int } class Lit(n: Int) extends Exp { def eval: Int = n } class Sub(l: Exp, r: Exp) extends Exp { def eval: Int = l.eval - r.eval } new Sub(new Lit(1), new Lit(2)).eval // algebraic datatype sealed trait Exp case class Lit(n: Int) extends Exp case class Sub(l: Exp, r: Exp) extends Exp // pattern matching function def eval(exp: Exp): Int = exp match { case Lit(n) => n case Sub(l, r) => eval(l) - eval(r) } eval(Sub(Lit(1), Lit(2))) e.g. extending simple arithmetic expressions and their operations… OOP FP
  • 6. Expression Problem 3 of datatypes and their operations // class hierarchy trait Exp { def eval: Int } class Lit(n: Int) extends Exp { def eval: Int = n } class Sub(l: Exp, r: Exp) extends Exp { def eval: Int = l.eval - r.eval } class Add(l: Exp, r: Exp) extends Exp { def eval: Int = l.eval + r.eval } new Sub(new Lit(1), new Lit(2)).eval Modular! OOP FP Describes the dilemma of modular extension e.g. extending simple arithmetic expressions and their operations… // algebraic datatype sealed trait Exp case class Lit(n: Int) extends Exp case class Sub(l: Exp, r: Exp) extends Exp // pattern matching function def eval(exp: Exp): Int = exp match { case Lit(n) => n case Sub(l, r) => eval(l) - eval(r) } eval(Sub(Lit(1), Lit(2))) Background
  • 7. Expression Problem 4 of datatypes and their operations trait Exp { def eval: Int def print: String } class Lit(n: Int) extends Exp { def eval: Int = n def print: String = .. } class Sub(l: Exp, r: Exp) extends Exp { def eval: Int = l.eval - r.eval def print: String = .. } class Add(l: Exp, r: Exp) extends Exp { def eval: Int = l.eval + r.eval def print: String = .. } new Sub(new Lit(1), new Lit(2)).eval OOP FP Non-Modular! Non-Modular! Non-Modular! Non-Modular! Describes the dilemma of modular extension e.g. extending simple arithmetic expressions and their operations… // algebraic datatype sealed trait Exp case class Lit(n: Int) extends Exp case class Sub(l: Exp, r: Exp) extends Exp // pattern matching function def eval(exp: Exp): Int = exp match { case Lit(n) => n case Sub(l, r) => eval(l) - eval(r) } eval(Sub(Lit(1), Lit(2))) Background
  • 8. Expression Problem 4 of datatypes and their operations trait Exp { def eval: Int def print: String } class Lit(n: Int) extends Exp { def eval: Int = n def print: String = .. } class Sub(l: Exp, r: Exp) extends Exp { def eval: Int = l.eval - r.eval def print: String = .. } class Add(l: Exp, r: Exp) extends Exp { def eval: Int = l.eval + r.eval def print: String = .. } new Sub(new Lit(1), new Lit(2)).eval OOP FP Non-Modular! Non-Modular! Non-Modular! Non-Modular! Modular extension of Datatypes ✅ Operations ❌ Describes the dilemma of modular extension e.g. extending simple arithmetic expressions and their operations… // algebraic datatype sealed trait Exp case class Lit(n: Int) extends Exp case class Sub(l: Exp, r: Exp) extends Exp // pattern matching function def eval(exp: Exp): Int = exp match { case Lit(n) => n case Sub(l, r) => eval(l) - eval(r) } eval(Sub(Lit(1), Lit(2))) Background
  • 9. Expression Problem 5 of datatypes and their operations trait Exp { def eval: Int def print: String } class Lit(n: Int) extends Exp { def eval: Int = n def print: String = .. } class Sub(l: Exp, r: Exp) extends Exp { def eval: Int = l.eval - r.eval def print: String = .. } class Add(l: Exp, r: Exp) extends Exp { def eval: Int = l.eval + r.eval def print: String = .. } new Sub(new Lit(1), new Lit(2)).eval // algebraic datatype sealed trait Exp case class Lit(n: Int) extends Exp case class Sub(l: Exp, r: Exp) extends Exp // pattern matching function def eval(exp: Exp): Int = exp match { case Lit(n) => n case Sub(l, r) => eval(l) - eval(r) } def print(exp: Exp): String = exp match { case Lit(n) => .. case Sub(l, r) => .. } eval(Sub(Lit(1), Lit(2))) OOP FP Non-Modular! Non-Modular! Non-Modular! Non-Modular! Modular extension of Datatypes ✅ Operations ❌ Describes the dilemma of modular extension Modular! e.g. extending simple arithmetic expressions and their operations… Background
  • 10. Expression Problem 6 of datatypes and their operations trait Exp { def eval: Int def print: String } class Lit(n: Int) extends Exp { def eval: Int = n def print: String = .. } class Sub(l: Exp, r: Exp) extends Exp { def eval: Int = l.eval - r.eval def print: String = .. } class Add(l: Exp, r: Exp) extends Exp { def eval: Int = l.eval + r.eval def print: String = .. } new Sub(new Lit(1), new Lit(2)).eval sealed trait Exp case class Lit(n: Int) extends Exp case class Sub(l: Exp, r: Exp) extends Exp case class Add(l: Exp, r: Exp) extends Exp // pattern matching function def eval(exp: Exp): Int = exp match { case Lit(n) => n case Sub(l, r) => eval(l) - eval(r) case Add(l, r) => .. } def print(exp: Exp): String = exp match { case Lit(n) => .. case Sub(l, r) => .. case Add(l, r) => .. } eval(Sub(Lit(1), Lit(2))) OOP FP Non-Modular! Non-Modular! Non-Modular! Non-Modular! Modular extension of Datatypes ✅ Operations ❌ Describes the dilemma of modular extension Non-Modular! Non-Modular! Non-Modular! e.g. extending simple arithmetic expressions and their operations… Background
  • 11. Expression Problem 6 of datatypes and their operations trait Exp { def eval: Int def print: String } class Lit(n: Int) extends Exp { def eval: Int = n def print: String = .. } class Sub(l: Exp, r: Exp) extends Exp { def eval: Int = l.eval - r.eval def print: String = .. } class Add(l: Exp, r: Exp) extends Exp { def eval: Int = l.eval + r.eval def print: String = .. } new Sub(new Lit(1), new Lit(2)).eval sealed trait Exp case class Lit(n: Int) extends Exp case class Sub(l: Exp, r: Exp) extends Exp case class Add(l: Exp, r: Exp) extends Exp // pattern matching function def eval(exp: Exp): Int = exp match { case Lit(n) => n case Sub(l, r) => eval(l) - eval(r) case Add(l, r) => .. } def print(exp: Exp): String = exp match { case Lit(n) => .. case Sub(l, r) => .. case Add(l, r) => .. } eval(Sub(Lit(1), Lit(2))) OOP FP Non-Modular! Non-Modular! Non-Modular! Non-Modular! Modular extension of Datatypes ✅ Operations ❌ Describes the dilemma of modular extension Non-Modular! Non-Modular! Non-Modular! Modular extension of Datatypes ❌ Operations ✅ e.g. extending simple arithmetic expressions and their operations… Background
  • 12. Compositional Programming* 7 Background Provides natural solutions to the Expression Problem Employs intersection types, a merge operator, and fi rst-class traits Novel programming paradigm featuring modularity *Weixin Zhang, Yaozhu Sun, and Bruno C. d. S. Oliveira. Compositional programming. ACM Transactions on Programming Languages and Systems (TOPLAS), 43(3):1–61, 2021.
  • 13. Compositional Programming 8 • Intersection types • Merge operator • First-class traits Background Novel programming paradigm featuring modularity
  • 14. Compositional Programming 8 • Intersection types • Merge operator • First-class traits Compose types with & Background Novel programming paradigm featuring modularity
  • 15. Compositional Programming 8 • Intersection types • Merge operator • First-class traits Compose types with & e.g. {a : A} & {b : B} == {a : A ; b : B} Background Novel programming paradigm featuring modularity
  • 16. Compositional Programming 8 • Intersection types • Merge operator • First-class traits Compose types with & e.g. {a : A} & {b : B} == {a : A ; b : B} Compose terms with ,, Introductory structure of intersection types Background Novel programming paradigm featuring modularity
  • 17. Compositional Programming 8 • Intersection types • Merge operator • First-class traits Compose types with & e.g. {a : A} & {b : B} == {a : A ; b : B} Compose terms with ,, Introductory structure of intersection types e.g. 1 ,, true has type Int & Bool Background Novel programming paradigm featuring modularity
  • 18. Compositional Programming 8 • Intersection types • Merge operator • First-class traits Compose types with & e.g. {a : A} & {b : B} == {a : A ; b : B} Compose terms with ,, Introductory structure of intersection types e.g. 1 ,, true has type Int & Bool Basic structures of Composition Programming Background Novel programming paradigm featuring modularity
  • 19. The CP Language 9 type NumSig<Exp> = { Lit: Int -> Exp; Add: Exp -> Exp -> Exp; }; Background Note: In CP the merge operator is `,` while it’s originally `,,`
  • 20. The CP Language 9 evalNum = trait implements NumSig<Eval> => { (Lit n).eval = n; (Add e1 e2).eval = e1.eval + e2.eval; }; type NumSig<Exp> = { Lit: Int -> Exp; Add: Exp -> Exp -> Exp; }; type Eval = { eval: Int }; Background Note: In CP the merge operator is `,` while it’s originally `,,`
  • 21. The CP Language 9 evalNum = trait implements NumSig<Eval> => { (Lit n).eval = n; (Add e1 e2).eval = e1.eval + e2.eval; }; type NumSig<Exp> = { Lit: Int -> Exp; Add: Exp -> Exp -> Exp; }; type Print = { print: String }; type Eval = { eval: Int }; Background printNum = trait implements NumSig<Print> => { (Lit n).print = toString n; (Add e1 e2).print = e1.print ++ "+" ++ e2.print; }; Note: In CP the merge operator is `,` while it’s originally `,,`
  • 22. The CP Language 9 evalNum = trait implements NumSig<Eval> => { (Lit n).eval = n; (Add e1 e2).eval = e1.eval + e2.eval; }; exp = new (repoNum @(Eval & Print) , evalNum , printNum); repoNum Exp = trait [self: NumSig<Exp>] => { num = Add (Lit 2) (Lit 3); }; type NumSig<Exp> = { Lit: Int -> Exp; Add: Exp -> Exp -> Exp; }; type Print = { print: String }; type Eval = { eval: Int }; Background printNum = trait implements NumSig<Print> => { (Lit n).print = toString n; (Add e1 e2).print = e1.print ++ "+" ++ e2.print; }; Note: In CP the merge operator is `,` while it’s originally `,,`
  • 23. The CP Language 9 evalNum = trait implements NumSig<Eval> => { (Lit n).eval = n; (Add e1 e2).eval = e1.eval + e2.eval; }; exp = new (repoNum @(Eval & Print) , evalNum , printNum); repoNum Exp = trait [self: NumSig<Exp>] => { num = Add (Lit 2) (Lit 3); }; Merge operator type NumSig<Exp> = { Lit: Int -> Exp; Add: Exp -> Exp -> Exp; }; type Print = { print: String }; type Eval = { eval: Int }; Background printNum = trait implements NumSig<Print> => { (Lit n).print = toString n; (Add e1 e2).print = e1.print ++ "+" ++ e2.print; }; Note: In CP the merge operator is `,` while it’s originally `,,`
  • 24. The CP Language 9 evalNum = trait implements NumSig<Eval> => { (Lit n).eval = n; (Add e1 e2).eval = e1.eval + e2.eval; }; exp = new (repoNum @(Eval & Print) , evalNum , printNum); repoNum Exp = trait [self: NumSig<Exp>] => { num = Add (Lit 2) (Lit 3); }; Intersection type argument Merge operator type NumSig<Exp> = { Lit: Int -> Exp; Add: Exp -> Exp -> Exp; }; type Print = { print: String }; type Eval = { eval: Int }; Background printNum = trait implements NumSig<Print> => { (Lit n).print = toString n; (Add e1 e2).print = e1.print ++ "+" ++ e2.print; }; Note: In CP the merge operator is `,` while it’s originally `,,`
  • 25. The CP Language 9 evalNum = trait implements NumSig<Eval> => { (Lit n).eval = n; (Add e1 e2).eval = e1.eval + e2.eval; }; exp = new (repoNum @(Eval & Print) , evalNum , printNum); repoNum Exp = trait [self: NumSig<Exp>] => { num = Add (Lit 2) (Lit 3); }; Intersection type argument Merge operator type NumSig<Exp> = { Lit: Int -> Exp; Add: Exp -> Exp -> Exp; }; type Print = { print: String }; type Eval = { eval: Int }; exp.num.eval —> 5 exp.num.print —> “2+3” Background printNum = trait implements NumSig<Print> => { (Lit n).print = toString n; (Add e1 e2).print = e1.print ++ "+" ++ e2.print; }; Note: In CP the merge operator is `,` while it’s originally `,,`
  • 26. evalNum = trait implements NumSig<Eval> => { (Lit n).eval = n; (Add e1 e2).eval = e1.eval + e2.eval; }; printNum = trait implements NumSig<Print> => { (Lit n).print = toString n; (Add e1 e2).print = e1.print ++ "+" ++ e2.print; }; type NumSig<Exp> = { Lit: Int -> Exp; Add: Exp -> Exp -> Exp; }; type Print = { print: String }; type Eval = { eval: Int }; type MulSig<Exp> = { Mul: Exp -> Exp -> Exp; }; Background The CP Language 10 Note: In CP the merge operator is `,` while it’s originally `,,`
  • 27. evalNum = trait implements NumSig<Eval> => { (Lit n).eval = n; (Add e1 e2).eval = e1.eval + e2.eval; }; printNum = trait implements NumSig<Print> => { (Lit n).print = toString n; (Add e1 e2).print = e1.print ++ "+" ++ e2.print; }; type NumSig<Exp> = { Lit: Int -> Exp; Add: Exp -> Exp -> Exp; }; type Print = { print: String }; type Eval = { eval: Int }; type MulSig<Exp> = { Mul: Exp -> Exp -> Exp; }; type ExpSig<Exp> = NumSig<Exp> & MulSig<Exp>; Background Intersection type The CP Language 10 Note: In CP the merge operator is `,` while it’s originally `,,`
  • 28. evalNum = trait implements NumSig<Eval> => { (Lit n).eval = n; (Add e1 e2).eval = e1.eval + e2.eval; }; printNum = trait implements NumSig<Print> => { (Lit n).print = toString n; (Add e1 e2).print = e1.print ++ "+" ++ e2.print; }; type NumSig<Exp> = { Lit: Int -> Exp; Add: Exp -> Exp -> Exp; }; type Print = { print: String }; type Eval = { eval: Int }; type MulSig<Exp> = { Mul: Exp -> Exp -> Exp; }; evalMul = trait implements MulSig<Eval> => { (Mul e1 e2).eval = e1.eval * e2.eval; }; type ExpSig<Exp> = NumSig<Exp> & MulSig<Exp>; Background Intersection type The CP Language 10 Note: In CP the merge operator is `,` while it’s originally `,,`
  • 29. evalNum = trait implements NumSig<Eval> => { (Lit n).eval = n; (Add e1 e2).eval = e1.eval + e2.eval; }; printNum = trait implements NumSig<Print> => { (Lit n).print = toString n; (Add e1 e2).print = e1.print ++ "+" ++ e2.print; }; type NumSig<Exp> = { Lit: Int -> Exp; Add: Exp -> Exp -> Exp; }; type Print = { print: String }; type Eval = { eval: Int }; type MulSig<Exp> = { Mul: Exp -> Exp -> Exp; }; evalMul = trait implements MulSig<Eval> => { (Mul e1 e2).eval = e1.eval * e2.eval; }; printMul = trait implements MulSig<Print> => { (Mul e1 e2).print = e1.print ++ "*" ++ e2.print; }; type ExpSig<Exp> = NumSig<Exp> & MulSig<Exp>; Background Intersection type The CP Language 10 Note: In CP the merge operator is `,` while it’s originally `,,`
  • 30. evalNum = trait implements NumSig<Eval> => { (Lit n).eval = n; (Add e1 e2).eval = e1.eval + e2.eval; }; printNum = trait implements NumSig<Print> => { (Lit n).print = toString n; (Add e1 e2).print = e1.print ++ "+" ++ e2.print; }; type NumSig<Exp> = { Lit: Int -> Exp; Add: Exp -> Exp -> Exp; }; type Print = { print: String }; type Eval = { eval: Int }; type MulSig<Exp> = { Mul: Exp -> Exp -> Exp; }; evalMul = trait implements MulSig<Eval> => { (Mul e1 e2).eval = e1.eval * e2.eval; }; printMul = trait implements MulSig<Print> => { (Mul e1 e2).print = e1.print ++ "*" ++ e2.print; }; type ExpSig<Exp> = NumSig<Exp> & MulSig<Exp>; repoExp Exp = trait [self: ExpSig<Exp>] => { mul = Mul (Lit 2) (Lit 3) }; Background Intersection type The CP Language 10 Note: In CP the merge operator is `,` while it’s originally `,,`
  • 31. evalNum = trait implements NumSig<Eval> => { (Lit n).eval = n; (Add e1 e2).eval = e1.eval + e2.eval; }; printNum = trait implements NumSig<Print> => { (Lit n).print = toString n; (Add e1 e2).print = e1.print ++ "+" ++ e2.print; }; type NumSig<Exp> = { Lit: Int -> Exp; Add: Exp -> Exp -> Exp; }; type Print = { print: String }; type Eval = { eval: Int }; type MulSig<Exp> = { Mul: Exp -> Exp -> Exp; }; evalMul = trait implements MulSig<Eval> => { (Mul e1 e2).eval = e1.eval * e2.eval; }; printMul = trait implements MulSig<Print> => { (Mul e1 e2).print = e1.print ++ "*" ++ e2.print; }; type ExpSig<Exp> = NumSig<Exp> & MulSig<Exp>; repoExp Exp = trait [self: ExpSig<Exp>] => { mul = Mul (Lit 2) (Lit 3) }; exp' = new (repoExp @(Eval & Print) , evalNum , evalMul , printNum , printMul); Background Intersection type Merge operator The CP Language 10 Note: In CP the merge operator is `,` while it’s originally `,,`
  • 32. evalNum = trait implements NumSig<Eval> => { (Lit n).eval = n; (Add e1 e2).eval = e1.eval + e2.eval; }; printNum = trait implements NumSig<Print> => { (Lit n).print = toString n; (Add e1 e2).print = e1.print ++ "+" ++ e2.print; }; type NumSig<Exp> = { Lit: Int -> Exp; Add: Exp -> Exp -> Exp; }; type Print = { print: String }; type Eval = { eval: Int }; type MulSig<Exp> = { Mul: Exp -> Exp -> Exp; }; evalMul = trait implements MulSig<Eval> => { (Mul e1 e2).eval = e1.eval * e2.eval; }; printMul = trait implements MulSig<Print> => { (Mul e1 e2).print = e1.print ++ "*" ++ e2.print; }; type ExpSig<Exp> = NumSig<Exp> & MulSig<Exp>; repoExp Exp = trait [self: ExpSig<Exp>] => { mul = Mul (Lit 2) (Lit 3) }; exp' = new (repoExp @(Eval & Print) , evalNum , evalMul , printNum , printMul); exp'.num.eval —> 6 exp'.num.print —> “2*3” Background Intersection type Merge operator The CP Language 10 Note: In CP the merge operator is `,` while it’s originally `,,`
  • 33. evalNum = trait implements NumSig<Eval> => { (Lit n).eval = n; (Add e1 e2).eval = e1.eval + e2.eval; }; printNum = trait implements NumSig<Print> => { (Lit n).print = toString n; (Add e1 e2).print = e1.print ++ "+" ++ e2.print; }; type NumSig<Exp> = { Lit: Int -> Exp; Add: Exp -> Exp -> Exp; }; type Print = { print: String }; type Eval = { eval: Int }; type MulSig<Exp> = { Mul: Exp -> Exp -> Exp; }; evalMul = trait implements MulSig<Eval> => { (Mul e1 e2).eval = e1.eval * e2.eval; }; printMul = trait implements MulSig<Print> => { (Mul e1 e2).print = e1.print ++ "*" ++ e2.print; }; type ExpSig<Exp> = NumSig<Exp> & MulSig<Exp>; repoExp Exp = trait [self: ExpSig<Exp>] => { mul = Mul (Lit 2) (Lit 3) }; exp' = new (repoExp @(Eval & Print) , evalNum , evalMul , printNum , printMul); exp'.num.eval —> 6 exp'.num.print —> “2*3” Background Intersection type Merge operator The CP Language 10 Note: In CP the merge operator is `,` while it’s originally `,,` repoExp + mul Lit + eval evalNum Add + eval printNum Lit + print Add + print evalMul Mul + eval printMul Mul + print , , , , = Lit + eval + print exp Mul + eval + print Add + eval + print + mul
  • 34. evalNum = trait implements NumSig<Eval> => { (Lit n).eval = n; (Add e1 e2).eval = e1.eval + e2.eval; }; printNum = trait implements NumSig<Print> => { (Lit n).print = toString n; (Add e1 e2).print = e1.print ++ "+" ++ e2.print; }; type NumSig<Exp> = { Lit: Int -> Exp; Add: Exp -> Exp -> Exp; }; type Print = { print: String }; type Eval = { eval: Int }; type MulSig<Exp> = { Mul: Exp -> Exp -> Exp; }; evalMul = trait implements MulSig<Eval> => { (Mul e1 e2).eval = e1.eval * e2.eval; }; printMul = trait implements MulSig<Print> => { (Mul e1 e2).print = e1.print ++ "*" ++ e2.print; }; type ExpSig<Exp> = NumSig<Exp> & MulSig<Exp>; repoExp Exp = trait [self: ExpSig<Exp>] => { mul = Mul (Lit 2) (Lit 3) }; exp' = new (repoExp @(Eval & Print) , evalNum , evalMul , printNum , printMul); exp'.num.eval —> 6 exp'.num.print —> “2*3” Background Intersection type Merge operator The CP Language 10 Note: In CP the merge operator is `,` while it’s originally `,,` Solves the EP Modular Dependency Injection Modular Context Evolution
  • 35. Disjoint Intersection Types* Background 11 Languages with the merge operator may be ambiguous *Bruno C. d. S. Oliveira, Zhiyuan Shi, and João Alpuim. Disjoint intersection types. In International Conference on Functional Programming (ICFP), 2016.
  • 36. Disjoint Intersection Types* Background 11 Languages with the merge operator may be ambiguous 1 ,, 2 has type Int & Int (1 , , 2) + 3 ⟶ ??? *Bruno C. d. S. Oliveira, Zhiyuan Shi, and João Alpuim. Disjoint intersection types. In International Conference on Functional Programming (ICFP), 2016.
  • 37. Disjoint Intersection Types* Background 11 Languages with the merge operator may be ambiguous 1 ,, 2 has type Int & Int (1 , , 2) + 3 ⟶ ??? Oliveira et al. proposed disjoint intersection types Reject ambiguous merges with overlapping types *Bruno C. d. S. Oliveira, Zhiyuan Shi, and João Alpuim. Disjoint intersection types. In International Conference on Functional Programming (ICFP), 2016.
  • 38. Disjoint Intersection Types* Background 11 Languages with the merge operator may be ambiguous 1 ,, 2 has type Int & Int (1 , , 2) + 3 ⟶ ??? Oliveira et al. proposed disjoint intersection types Reject ambiguous merges with overlapping types Type is disjoint to type (i.e. ) A B A * B ≐ For all type if and then C A <: C B <: C C ∼ 𝖳 𝗈 𝗉 *Bruno C. d. S. Oliveira, Zhiyuan Shi, and João Alpuim. Disjoint intersection types. In International Conference on Functional Programming (ICFP), 2016.
  • 39. Disjoint Intersection Types* Background 11 Languages with the merge operator may be ambiguous 1 ,, 2 has type Int & Int (1 , , 2) + 3 ⟶ ??? Oliveira et al. proposed disjoint intersection types Reject ambiguous merges with overlapping types Type is disjoint to type (i.e. ) A B A * B ≐ For all type if and then C A <: C B <: C C ∼ 𝖳 𝗈 𝗉 Type equivalence *Bruno C. d. S. Oliveira, Zhiyuan Shi, and João Alpuim. Disjoint intersection types. In International Conference on Functional Programming (ICFP), 2016.
  • 40. Disjoint Intersection Types* Background 11 Languages with the merge operator may be ambiguous 1 ,, 2 has type Int & Int (1 , , 2) + 3 ⟶ ??? Oliveira et al. proposed disjoint intersection types Reject ambiguous merges with overlapping types Type is disjoint to type (i.e. ) A B A * B ≐ For all type if and then C A <: C B <: C C ∼ 𝖳 𝗈 𝗉 Type equivalence Int is the common supertype of Int itself *Bruno C. d. S. Oliveira, Zhiyuan Shi, and João Alpuim. Disjoint intersection types. In International Conference on Functional Programming (ICFP), 2016.
  • 41. Disjoint Intersection Types* Background 11 Languages with the merge operator may be ambiguous 1 ,, 2 has type Int & Int (1 , , 2) + 3 ⟶ ??? Oliveira et al. proposed disjoint intersection types Reject ambiguous merges with overlapping types Type is disjoint to type (i.e. ) A B A * B ≐ For all type if and then C A <: C B <: C C ∼ 𝖳 𝗈 𝗉 Type equivalence Int is the common supertype of Int itself Int * Int, therefore 1 ,, 2 is rejected *Bruno C. d. S. Oliveira, Zhiyuan Shi, and João Alpuim. Disjoint intersection types. In International Conference on Functional Programming (ICFP), 2016.
  • 42. 12 Motivation The Calculus - CP’s Foundation 𝖥 + i A polymorphic calculus with disjoint intersection types and a merge operator
  • 43. 13 Motivation The Calculus - CP’s Foundation 𝖥 + i A polymorphic calculus with disjoint intersection types and a merge operator
  • 44. 13 Motivation The Calculus - CP’s Foundation 𝖥 + i A polymorphic calculus with disjoint intersection types and a merge operator The current formulation of 𝖥 + i based on an elaboration semantics
  • 45. 13 Motivation The Calculus - CP’s Foundation 𝖥 + i A polymorphic calculus with disjoint intersection types and a merge operator The current formulation of 𝖥 + i • Lack of impredicative polymorphism • Lack of recursion its coherence proof causes… based on an elaboration semantics
  • 46. 13 Motivation The Calculus - CP’s Foundation 𝖥 + i A polymorphic calculus with disjoint intersection types and a merge operator The current formulation of 𝖥 + i • Lack of impredicative polymorphism • Lack of recursion While CP allows the creation of objects with polymorphic methods its coherence proof causes… based on an elaboration semantics
  • 47. 14 Motivation The Calculus - CP’s Foundation 𝖥 + i The current formulation of 𝖥 + i • Lack of impredicative polymorphism • Lack of recursion its coherence proof causes… based on an elaboration semantics While CP’s elaboration of traits… ↝ A polymorphic calculus with disjoint intersection types and a merge operator
  • 48. 15 Motivation The Calculus - CP’s Foundation 𝖥 + i The current formulation of 𝖥 + i its coherence proof causes… based on an elaboration semantics While CP’s elaboration of traits… ↝ A polymorphic calculus with disjoint intersection types and a merge operator • Lack of impredicative polymorphism • Lack of recursion
  • 49. 16 Motivation The Calculus - CP’s Foundation 𝖥 + i The current formulation of 𝖥 + i • Di ff erence in evaluation strategies its coherence proof causes… based on an elaboration semantics While call-by-value will diverge in… • CP assumed call-by-name • is call-by-value 𝖥 + i A polymorphic calculus with disjoint intersection types and a merge operator Note: CP is implemented as call-by-need • Lack of impredicative polymorphism • Lack of recursion
  • 50. 17 Motivation The Calculus - CP’s Foundation 𝖥 + i The current formulation of 𝖥 + i • Di ff erence in evaluation strategies its coherence proof causes… based on an elaboration semantics • CP assumed call-by-name • is call-by-value 𝖥 + i }The gap between theory & practice A polymorphic calculus with disjoint intersection types and a merge operator Note: CP is implemented as call-by-need • Lack of impredicative polymorphism • Lack of recursion
  • 51. 18 Our Contribution The Calculus - CP’s Foundation 𝖥 + i The new formulation of 𝖥 + i its determinism proof is simple based on a direct Type-Directed Operational Semantics* • CP assumed call-by-name • is call-by-name 𝖥 + i }The gap between theory & practice • Lack of impredicative polymorphism • Lack of recursion • Di ff erence in evaluation strategies A polymorphic calculus with disjoint intersection types and a merge operator Note: CP is implemented as call-by-need *Xuejing Huang and Bruno C. d. S. Oliveira. A type-directed operational semantics for a calculus with a merge operator. In 34th European Conference on Object-Oriented Programming (ECOOP 2020), volume 166 of Leibniz International Proceedings in Informatics (LIPIcs), pages 26:1–26:32.
  • 52. 18 Our Contribution The Calculus - CP’s Foundation 𝖥 + i The new formulation of 𝖥 + i its determinism proof is simple based on a direct Type-Directed Operational Semantics* • CP assumed call-by-name • is call-by-name 𝖥 + i }The gap between theory & practice • Lack of impredicative polymorphism • Lack of recursion • Di ff erence in evaluation strategies A polymorphic calculus with disjoint intersection types and a merge operator Note: CP is implemented as call-by-need *Xuejing Huang and Bruno C. d. S. Oliveira. A type-directed operational semantics for a calculus with a merge operator. In 34th European Conference on Object-Oriented Programming (ECOOP 2020), volume 166 of Leibniz International Proceedings in Informatics (LIPIcs), pages 26:1–26:32.
  • 53. 18 Our Contribution The Calculus - CP’s Foundation 𝖥 + i The new formulation of 𝖥 + i its determinism proof is simple based on a direct Type-Directed Operational Semantics* • CP assumed call-by-name • is call-by-name 𝖥 + i }The gap between theory & practice • Lack of impredicative polymorphism • Lack of recursion • Di ff erence in evaluation strategies A polymorphic calculus with disjoint intersection types and a merge operator Note: CP is implemented as call-by-need *Xuejing Huang and Bruno C. d. S. Oliveira. A type-directed operational semantics for a calculus with a merge operator. In 34th European Conference on Object-Oriented Programming (ECOOP 2020), volume 166 of Leibniz International Proceedings in Informatics (LIPIcs), pages 26:1–26:32.
  • 54. 18 Our Contribution The Calculus - CP’s Foundation 𝖥 + i The new formulation of 𝖥 + i its determinism proof is simple based on a direct Type-Directed Operational Semantics* • CP assumed call-by-name • is call-by-name 𝖥 + i }The gap between theory & practice • Lack of impredicative polymorphism • Lack of recursion • Di ff erence in evaluation strategies A polymorphic calculus with disjoint intersection types and a merge operator Note: CP is implemented as call-by-need *Xuejing Huang and Bruno C. d. S. Oliveira. A type-directed operational semantics for a calculus with a merge operator. In 34th European Conference on Object-Oriented Programming (ECOOP 2020), volume 166 of Leibniz International Proceedings in Informatics (LIPIcs), pages 26:1–26:32.
  • 55. 18 Our Contribution The Calculus - CP’s Foundation 𝖥 + i The new formulation of 𝖥 + i its determinism proof is simple based on a direct Type-Directed Operational Semantics* • CP assumed call-by-name • is call-by-name 𝖥 + i }The gap between theory & practice • Lack of impredicative polymorphism • Lack of recursion • Di ff erence in evaluation strategies A polymorphic calculus with disjoint intersection types and a merge operator Note: CP is implemented as call-by-need *Xuejing Huang and Bruno C. d. S. Oliveira. A type-directed operational semantics for a calculus with a merge operator. In 34th European Conference on Object-Oriented Programming (ECOOP 2020), volume 166 of Leibniz International Proceedings in Informatics (LIPIcs), pages 26:1–26:32.
  • 56. The Calculus 𝖥 + i Example 19 type LitSig<Exp> = { Lit: Int -> Exp }; type Eval = { eval: Int }; type Print = { print: String }; evalLit = trait implements LigSig<Eval> => { (Lit n).eval = n; } printLit = trait implements LigSig<Print> => { (Lit n).print = toString n; } repoLit Exp = trait [self: LitSig<Exp>] => { num = Lit ((1+1) , true); }; (new repoLit @(Eval & Print) , evalLit , printLit).num
  • 57. The Calculus 𝖥 + i Example 19 type LitSig<Exp> = { Lit: Int -> Exp }; type Eval = { eval: Int }; type Print = { print: String }; evalLit = trait implements LigSig<Eval> => { (Lit n).eval = n; } printLit = trait implements LigSig<Print> => { (Lit n).print = toString n; } repoLit Exp = trait [self: LitSig<Exp>] => { num = Lit ((1+1) , true); }; (new repoLit @(Eval & Print) , evalLit , printLit).num
  • 58. The Calculus 𝖥 + i Example 19 type LitSig<Exp> = { Lit: Int -> Exp }; type Eval = { eval: Int }; type Print = { print: String }; evalLit = trait implements LigSig<Eval> => { (Lit n).eval = n; } printLit = trait implements LigSig<Print> => { (Lit n).print = toString n; } repoLit Exp = trait [self: LitSig<Exp>] => { num = Lit ((1+1) , true); }; (new repoLit @(Eval & Print) , evalLit , printLit).num ({ 𝖫 𝗂 𝗍 = f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 }} , , { 𝖫 𝗂 𝗍 = g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }}) . 𝖫 𝗂 𝗍 ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ↝ after simpli fi cation
  • 59. The Calculus 𝖥 + i Example 19 type LitSig<Exp> = { Lit: Int -> Exp }; type Eval = { eval: Int }; type Print = { print: String }; evalLit = trait implements LigSig<Eval> => { (Lit n).eval = n; } printLit = trait implements LigSig<Print> => { (Lit n).print = toString n; } repoLit Exp = trait [self: LitSig<Exp>] => { num = Lit ((1+1) , true); }; (new repoLit @(Eval & Print) , evalLit , printLit).num ({ 𝖫 𝗂 𝗍 = f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 }} , , { 𝖫 𝗂 𝗍 = g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }}) . 𝖫 𝗂 𝗍 ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ↝ after simpli fi cation g := (λx : 𝖨 𝗇 𝗍 . { 𝗉 𝗋 𝗂 𝗇 𝗍 = 𝗍 𝗈 𝖲 𝗍 𝗋 𝗂 𝗇 𝗀 x}) f := (λx : 𝖨 𝗇 𝗍 . { 𝖾 𝗏 𝖺 𝗅 = x})
  • 60. The Calculus 𝖥 + i Example 19 type LitSig<Exp> = { Lit: Int -> Exp }; type Eval = { eval: Int }; type Print = { print: String }; evalLit = trait implements LigSig<Eval> => { (Lit n).eval = n; } printLit = trait implements LigSig<Print> => { (Lit n).print = toString n; } repoLit Exp = trait [self: LitSig<Exp>] => { num = Lit ((1+1) , true); }; (new repoLit @(Eval & Print) , evalLit , printLit).num ({ 𝖫 𝗂 𝗍 = f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 }} , , { 𝖫 𝗂 𝗍 = g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }}) . 𝖫 𝗂 𝗍 ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ↝ after simpli fi cation g := (λx : 𝖨 𝗇 𝗍 . { 𝗉 𝗋 𝗂 𝗇 𝗍 = 𝗍 𝗈 𝖲 𝗍 𝗋 𝗂 𝗇 𝗀 x}) f := (λx : 𝖨 𝗇 𝗍 . { 𝖾 𝗏 𝖺 𝗅 = x})
  • 61. The Calculus 𝖥 + i Example 19 type LitSig<Exp> = { Lit: Int -> Exp }; type Eval = { eval: Int }; type Print = { print: String }; evalLit = trait implements LigSig<Eval> => { (Lit n).eval = n; } printLit = trait implements LigSig<Print> => { (Lit n).print = toString n; } repoLit Exp = trait [self: LitSig<Exp>] => { num = Lit ((1+1) , true); }; (new repoLit @(Eval & Print) , evalLit , printLit).num ({ 𝖫 𝗂 𝗍 = f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 }} , , { 𝖫 𝗂 𝗍 = g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }}) . 𝖫 𝗂 𝗍 ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ↝ after simpli fi cation ↪ (f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } , , g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) g := (λx : 𝖨 𝗇 𝗍 . { 𝗉 𝗋 𝗂 𝗇 𝗍 = 𝗍 𝗈 𝖲 𝗍 𝗋 𝗂 𝗇 𝗀 x}) f := (λx : 𝖨 𝗇 𝗍 . { 𝖾 𝗏 𝖺 𝗅 = x})
  • 62. The Calculus 𝖥 + i 20 Example Dynamic ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) (f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } , , g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) g := (λx : 𝖨 𝗇 𝗍 . { 𝗉 𝗋 𝗂 𝗇 𝗍 = 𝗍 𝗈 𝖲 𝗍 𝗋 𝗂 𝗇 𝗀 x}) f := (λx : 𝖨 𝗇 𝗍 . { 𝖾 𝗏 𝖺 𝗅 = x})
  • 63. The Calculus 𝖥 + i 20 Example Dynamic ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ↪ Parallel application (f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } , , g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) g := (λx : 𝖨 𝗇 𝗍 . { 𝗉 𝗋 𝗂 𝗇 𝗍 = 𝗍 𝗈 𝖲 𝗍 𝗋 𝗂 𝗇 𝗀 x}) f := (λx : 𝖨 𝗇 𝗍 . { 𝖾 𝗏 𝖺 𝗅 = x})
  • 64. The Calculus 𝖥 + i 20 Example Dynamic ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ↪ Parallel application (f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } , , g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) g := (λx : 𝖨 𝗇 𝗍 . { 𝗉 𝗋 𝗂 𝗇 𝗍 = 𝗍 𝗈 𝖲 𝗍 𝗋 𝗂 𝗇 𝗀 x}) f := (λx : 𝖨 𝗇 𝗍 . { 𝖾 𝗏 𝖺 𝗅 = x})
  • 65. The Calculus 𝖥 + i 20 Example Dynamic ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) : 𝖨 𝗇 𝗍 : 𝖨 𝗇 𝗍 ↪ Parallel application (f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } , , g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) g := (λx : 𝖨 𝗇 𝗍 . { 𝗉 𝗋 𝗂 𝗇 𝗍 = 𝗍 𝗈 𝖲 𝗍 𝗋 𝗂 𝗇 𝗀 x}) f := (λx : 𝖨 𝗇 𝗍 . { 𝖾 𝗏 𝖺 𝗅 = x})
  • 66. The Calculus 𝖥 + i 20 Example Dynamic ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) : 𝖨 𝗇 𝗍 : 𝖨 𝗇 𝗍 Call-by-name ↪ Parallel application (f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } , , g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) g := (λx : 𝖨 𝗇 𝗍 . { 𝗉 𝗋 𝗂 𝗇 𝗍 = 𝗍 𝗈 𝖲 𝗍 𝗋 𝗂 𝗇 𝗀 x}) f := (λx : 𝖨 𝗇 𝗍 . { 𝖾 𝗏 𝖺 𝗅 = x}) { 𝖾 𝗏 𝖺 𝗅 = ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) : 𝖨 𝗇 𝗍 } , , { 𝗉 𝗋 𝗂 𝗇 𝗍 = 𝗍 𝗈 𝖲 𝗍 𝗋 𝗂 𝗇 𝗀 ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) : 𝖨 𝗇 𝗍 } Value!
  • 67. The Calculus 𝖥 + i 20 Example Dynamic ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) : 𝖨 𝗇 𝗍 : 𝖨 𝗇 𝗍 Call-by-name ↪ Parallel application (f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } , , g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) g := (λx : 𝖨 𝗇 𝗍 . { 𝗉 𝗋 𝗂 𝗇 𝗍 = 𝗍 𝗈 𝖲 𝗍 𝗋 𝗂 𝗇 𝗀 x}) f := (λx : 𝖨 𝗇 𝗍 . { 𝖾 𝗏 𝖺 𝗅 = x}) { 𝖾 𝗏 𝖺 𝗅 = ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) : 𝖨 𝗇 𝗍 } , , { 𝗉 𝗋 𝗂 𝗇 𝗍 = 𝗍 𝗈 𝖲 𝗍 𝗋 𝗂 𝗇 𝗀 ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) : 𝖨 𝗇 𝗍 } Consider projecting out… 𝖾 𝗏 𝖺 𝗅 ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) : 𝖨 𝗇 𝗍 Value!
  • 68. The Calculus 𝖥 + i 20 Example Dynamic ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) : 𝖨 𝗇 𝗍 : 𝖨 𝗇 𝗍 Call-by-name ↪ Parallel application ↪ Evaluate the merge Evaluate the merge (f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } , , g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) g := (λx : 𝖨 𝗇 𝗍 . { 𝗉 𝗋 𝗂 𝗇 𝗍 = 𝗍 𝗈 𝖲 𝗍 𝗋 𝗂 𝗇 𝗀 x}) f := (λx : 𝖨 𝗇 𝗍 . { 𝖾 𝗏 𝖺 𝗅 = x}) { 𝖾 𝗏 𝖺 𝗅 = ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) : 𝖨 𝗇 𝗍 } , , { 𝗉 𝗋 𝗂 𝗇 𝗍 = 𝗍 𝗈 𝖲 𝗍 𝗋 𝗂 𝗇 𝗀 ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) : 𝖨 𝗇 𝗍 } Consider projecting out… 𝖾 𝗏 𝖺 𝗅 ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) : 𝖨 𝗇 𝗍 Value!
  • 69. The Calculus 𝖥 + i 20 Example Dynamic (2 , , 𝗍 𝗋 𝗎 𝖾 ) : 𝖨 𝗇 𝗍 ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) : 𝖨 𝗇 𝗍 : 𝖨 𝗇 𝗍 Call-by-name ↪ Parallel application ↪ Evaluate the merge Evaluate the merge Lazy evaluation (f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } , , g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) g := (λx : 𝖨 𝗇 𝗍 . { 𝗉 𝗋 𝗂 𝗇 𝗍 = 𝗍 𝗈 𝖲 𝗍 𝗋 𝗂 𝗇 𝗀 x}) f := (λx : 𝖨 𝗇 𝗍 . { 𝖾 𝗏 𝖺 𝗅 = x}) { 𝖾 𝗏 𝖺 𝗅 = ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) : 𝖨 𝗇 𝗍 } , , { 𝗉 𝗋 𝗂 𝗇 𝗍 = 𝗍 𝗈 𝖲 𝗍 𝗋 𝗂 𝗇 𝗀 ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) : 𝖨 𝗇 𝗍 } Consider projecting out… 𝖾 𝗏 𝖺 𝗅 ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) : 𝖨 𝗇 𝗍 Value!
  • 70. The Calculus 𝖥 + i 20 Example Dynamic (2 , , 𝗍 𝗋 𝗎 𝖾 ) : 𝖨 𝗇 𝗍 ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) : 𝖨 𝗇 𝗍 : 𝖨 𝗇 𝗍 Call-by-name ↪ Parallel application ↪ Evaluate the merge Evaluate the merge Lazy evaluation ↪ Casting (f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } , , g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) g := (λx : 𝖨 𝗇 𝗍 . { 𝗉 𝗋 𝗂 𝗇 𝗍 = 𝗍 𝗈 𝖲 𝗍 𝗋 𝗂 𝗇 𝗀 x}) f := (λx : 𝖨 𝗇 𝗍 . { 𝖾 𝗏 𝖺 𝗅 = x}) { 𝖾 𝗏 𝖺 𝗅 = ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) : 𝖨 𝗇 𝗍 } , , { 𝗉 𝗋 𝗂 𝗇 𝗍 = 𝗍 𝗈 𝖲 𝗍 𝗋 𝗂 𝗇 𝗀 ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) : 𝖨 𝗇 𝗍 } Consider projecting out… 𝖾 𝗏 𝖺 𝗅 ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) : 𝖨 𝗇 𝗍 Value!
  • 71. The Calculus 𝖥 + i 20 Example Dynamic (2 , , 𝗍 𝗋 𝗎 𝖾 ) : 𝖨 𝗇 𝗍 2 ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) : 𝖨 𝗇 𝗍 : 𝖨 𝗇 𝗍 Call-by-name ↪ Parallel application ↪ Evaluate the merge Evaluate the merge Lazy evaluation ↪ Casting Select the desired value with type annotations (f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } , , g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) g := (λx : 𝖨 𝗇 𝗍 . { 𝗉 𝗋 𝗂 𝗇 𝗍 = 𝗍 𝗈 𝖲 𝗍 𝗋 𝗂 𝗇 𝗀 x}) f := (λx : 𝖨 𝗇 𝗍 . { 𝖾 𝗏 𝖺 𝗅 = x}) { 𝖾 𝗏 𝖺 𝗅 = ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) : 𝖨 𝗇 𝗍 } , , { 𝗉 𝗋 𝗂 𝗇 𝗍 = 𝗍 𝗈 𝖲 𝗍 𝗋 𝗂 𝗇 𝗀 ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) : 𝖨 𝗇 𝗍 } Consider projecting out… 𝖾 𝗏 𝖺 𝗅 ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) : 𝖨 𝗇 𝗍 Value!
  • 72. The Calculus 𝖥 + i Example 21 ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ⇒ (f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } , , g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) g := (λx : 𝖨 𝗇 𝗍 . { 𝗉 𝗋 𝗂 𝗇 𝗍 = 𝗍 𝗈 𝖲 𝗍 𝗋 𝗂 𝗇 𝗀 x}) f := (λx : 𝖨 𝗇 𝗍 . { 𝖾 𝗏 𝖺 𝗅 = x}) Static
  • 73. The Calculus 𝖥 + i Example 21 ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ⇒ Type synthesis (f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } , , g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) g := (λx : 𝖨 𝗇 𝗍 . { 𝗉 𝗋 𝗂 𝗇 𝗍 = 𝗍 𝗈 𝖲 𝗍 𝗋 𝗂 𝗇 𝗀 x}) f := (λx : 𝖨 𝗇 𝗍 . { 𝖾 𝗏 𝖺 𝗅 = x}) Static
  • 74. The Calculus 𝖥 + i Example 21 ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ⇒ (f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } , , g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) ⇒ Type synthesis (f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } , , g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) g := (λx : 𝖨 𝗇 𝗍 . { 𝗉 𝗋 𝗂 𝗇 𝗍 = 𝗍 𝗈 𝖲 𝗍 𝗋 𝗂 𝗇 𝗀 x}) f := (λx : 𝖨 𝗇 𝗍 . { 𝖾 𝗏 𝖺 𝗅 = x}) Static
  • 75. The Calculus 𝖥 + i Example 21 ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ⇒ (f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } , , g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) ⇒ Type synthesis (f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } , , g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) g := (λx : 𝖨 𝗇 𝗍 . { 𝗉 𝗋 𝗂 𝗇 𝗍 = 𝗍 𝗈 𝖲 𝗍 𝗋 𝗂 𝗇 𝗀 x}) f := (λx : 𝖨 𝗇 𝗍 . { 𝖾 𝗏 𝖺 𝗅 = x}) Static ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ⇐
  • 76. The Calculus 𝖥 + i Example 21 ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ⇒ (f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } , , g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) ⇒ Type synthesis (f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } , , g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) g := (λx : 𝖨 𝗇 𝗍 . { 𝗉 𝗋 𝗂 𝗇 𝗍 = 𝗍 𝗈 𝖲 𝗍 𝗋 𝗂 𝗇 𝗀 x}) f := (λx : 𝖨 𝗇 𝗍 . { 𝖾 𝗏 𝖺 𝗅 = x}) Static Type checking ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ⇐
  • 77. The Calculus 𝖥 + i Example 21 ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ⇒ (f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } , , g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) ⇒ (f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } , , g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) g := (λx : 𝖨 𝗇 𝗍 . { 𝗉 𝗋 𝗂 𝗇 𝗍 = 𝗍 𝗈 𝖲 𝗍 𝗋 𝗂 𝗇 𝗀 x}) f := (λx : 𝖨 𝗇 𝗍 . { 𝖾 𝗏 𝖺 𝗅 = x}) Static ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ⇐
  • 78. The Calculus 𝖥 + i Example 21 ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ⇒ (f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } , , g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) ⇒ f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } ⇒ g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }⇒ (f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } , , g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) g := (λx : 𝖨 𝗇 𝗍 . { 𝗉 𝗋 𝗂 𝗇 𝗍 = 𝗍 𝗈 𝖲 𝗍 𝗋 𝗂 𝗇 𝗀 x}) f := (λx : 𝖨 𝗇 𝗍 . { 𝖾 𝗏 𝖺 𝗅 = x}) Static ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ⇐
  • 79. The Calculus 𝖥 + i Example 21 ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ⇒ (f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } , , g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) ⇒ f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } ⇒ g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }⇒ 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } (f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } , , g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) g := (λx : 𝖨 𝗇 𝗍 . { 𝗉 𝗋 𝗂 𝗇 𝗍 = 𝗍 𝗈 𝖲 𝗍 𝗋 𝗂 𝗇 𝗀 x}) f := (λx : 𝖨 𝗇 𝗍 . { 𝖾 𝗏 𝖺 𝗅 = x}) Static ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ⇐
  • 80. The Calculus 𝖥 + i Example 21 ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ⇒ (f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } , , g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) ⇒ f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } ⇒ g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }⇒ 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 } (f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } , , g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) g := (λx : 𝖨 𝗇 𝗍 . { 𝗉 𝗋 𝗂 𝗇 𝗍 = 𝗍 𝗈 𝖲 𝗍 𝗋 𝗂 𝗇 𝗀 x}) f := (λx : 𝖨 𝗇 𝗍 . { 𝖾 𝗏 𝖺 𝗅 = x}) Static ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ⇐
  • 81. The Calculus 𝖥 + i Example 21 ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ⇒ (f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } , , g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) ⇒ f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } ⇒ g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }⇒ 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 } 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 } * (f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } , , g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) g := (λx : 𝖨 𝗇 𝗍 . { 𝗉 𝗋 𝗂 𝗇 𝗍 = 𝗍 𝗈 𝖲 𝗍 𝗋 𝗂 𝗇 𝗀 x}) f := (λx : 𝖨 𝗇 𝗍 . { 𝖾 𝗏 𝖺 𝗅 = x}) Static ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ⇐
  • 82. The Calculus 𝖥 + i Example 21 ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ⇒ (f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } , , g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) ⇒ f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } ⇒ g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }⇒ 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 } 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 } * ( 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 }) ( 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) & (f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } , , g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) g := (λx : 𝖨 𝗇 𝗍 . { 𝗉 𝗋 𝗂 𝗇 𝗍 = 𝗍 𝗈 𝖲 𝗍 𝗋 𝗂 𝗇 𝗀 x}) f := (λx : 𝖨 𝗇 𝗍 . { 𝖾 𝗏 𝖺 𝗅 = x}) Static ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ⇐
  • 83. The Calculus 𝖥 + i Example 22 ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ⇒ (f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } , , g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) ⇒( 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 }) ( 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) & (f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } , , g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) g := (λx : 𝖨 𝗇 𝗍 . { 𝗉 𝗋 𝗂 𝗇 𝗍 = 𝗍 𝗈 𝖲 𝗍 𝗋 𝗂 𝗇 𝗀 x}) f := (λx : 𝖨 𝗇 𝗍 . { 𝖾 𝗏 𝖺 𝗅 = x}) Static ⊳ 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } & { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 } ( 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 }) ( 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) & ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ⇐
  • 84. The Calculus 𝖥 + i Example 22 ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ⇒ (f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } , , g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) ⇒( 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 }) ( 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) & (f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } , , g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) g := (λx : 𝖨 𝗇 𝗍 . { 𝗉 𝗋 𝗂 𝗇 𝗍 = 𝗍 𝗈 𝖲 𝗍 𝗋 𝗂 𝗇 𝗀 x}) f := (λx : 𝖨 𝗇 𝗍 . { 𝖾 𝗏 𝖺 𝗅 = x}) Static ⊳ Applicative distribution 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } & { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 } ( 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 }) ( 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) & ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ⇐
  • 85. The Calculus 𝖥 + i Example 22 ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ⇒ (f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } , , g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) ⇒( 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 }) ( 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) & (f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } , , g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) g := (λx : 𝖨 𝗇 𝗍 . { 𝗉 𝗋 𝗂 𝗇 𝗍 = 𝗍 𝗈 𝖲 𝗍 𝗋 𝗂 𝗇 𝗀 x}) f := (λx : 𝖨 𝗇 𝗍 . { 𝖾 𝗏 𝖺 𝗅 = x}) Static ⊳ Applicative distribution 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } & { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 } ( 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 }) ( 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) & (A → B1) & (A → B2) <: A → B1 & B2 ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ⇐
  • 86. The Calculus 𝖥 + i Example 23 ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ⇒ (f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } , , g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) ⇒( 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 }) ( 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) & (f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } , , g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) g := (λx : 𝖨 𝗇 𝗍 . { 𝗉 𝗋 𝗂 𝗇 𝗍 = 𝗍 𝗈 𝖲 𝗍 𝗋 𝗂 𝗇 𝗀 x}) f := (λx : 𝖨 𝗇 𝗍 . { 𝖾 𝗏 𝖺 𝗅 = x}) Static ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ⇐ ⊳ Applicative distribution 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } & { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 } ( 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 }) ( 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) & (A → B1) & (A → B2) <: A → B1 & B2 𝖨 𝗇 𝗍
  • 87. The Calculus 𝖥 + i Example 23 ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ⇒ (f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } , , g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) ⇒( 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 }) ( 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) & (f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } , , g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) g := (λx : 𝖨 𝗇 𝗍 . { 𝗉 𝗋 𝗂 𝗇 𝗍 = 𝗍 𝗈 𝖲 𝗍 𝗋 𝗂 𝗇 𝗀 x}) f := (λx : 𝖨 𝗇 𝗍 . { 𝖾 𝗏 𝖺 𝗅 = x}) Static ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ⇐ ⊳ Applicative distribution 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } & { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 } ( 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 }) ( 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) & (A → B1) & (A → B2) <: A → B1 & B2 𝖨 𝗇 𝗍 ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ⇒
  • 88. The Calculus 𝖥 + i Example 23 ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ⇒ (f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } , , g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) ⇒( 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 }) ( 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) & (f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } , , g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) g := (λx : 𝖨 𝗇 𝗍 . { 𝗉 𝗋 𝗂 𝗇 𝗍 = 𝗍 𝗈 𝖲 𝗍 𝗋 𝗂 𝗇 𝗀 x}) f := (λx : 𝖨 𝗇 𝗍 . { 𝖾 𝗏 𝖺 𝗅 = x}) Static ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ⇐ ⊳ Applicative distribution 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } & { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 } ( 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 }) ( 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) & (A → B1) & (A → B2) <: A → B1 & B2 𝖨 𝗇 𝗍 ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ⇒ 𝖨 𝗇 𝗍 & 𝖡 𝗈 𝗈 𝗅
  • 89. The Calculus 𝖥 + i Example 23 ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ⇒ (f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } , , g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) ⇒( 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 }) ( 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) & (f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } , , g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) g := (λx : 𝖨 𝗇 𝗍 . { 𝗉 𝗋 𝗂 𝗇 𝗍 = 𝗍 𝗈 𝖲 𝗍 𝗋 𝗂 𝗇 𝗀 x}) f := (λx : 𝖨 𝗇 𝗍 . { 𝖾 𝗏 𝖺 𝗅 = x}) Static ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ⇐ ⊳ Applicative distribution 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } & { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 } ( 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 }) ( 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) & (A → B1) & (A → B2) <: A → B1 & B2 𝖨 𝗇 𝗍 ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ⇒ 𝖨 𝗇 𝗍 & 𝖡 𝗈 𝗈 𝗅 𝖨 𝗇 𝗍 & 𝖡 𝗈 𝗈 𝗅 <: 𝖨 𝗇 𝗍
  • 90. The Calculus 𝖥 + i Example 23 ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ⇒ (f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } , , g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) ⇒( 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 }) ( 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) & (f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } , , g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) g := (λx : 𝖨 𝗇 𝗍 . { 𝗉 𝗋 𝗂 𝗇 𝗍 = 𝗍 𝗈 𝖲 𝗍 𝗋 𝗂 𝗇 𝗀 x}) f := (λx : 𝖨 𝗇 𝗍 . { 𝖾 𝗏 𝖺 𝗅 = x}) Static ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ⇐ ⊳ Applicative distribution 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } & { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 } ( 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 }) ( 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) & (A → B1) & (A → B2) <: A → B1 & B2 𝖨 𝗇 𝗍 ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ⇒ 𝖨 𝗇 𝗍 & 𝖡 𝗈 𝗈 𝗅 𝖨 𝗇 𝗍 & 𝖡 𝗈 𝗈 𝗅 <: 𝖨 𝗇 𝗍
  • 91. The Calculus 𝖥 + i Example 23 ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ⇒ (f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } , , g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) ⇒( 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 }) ( 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) & (f : 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } , , g : 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) g := (λx : 𝖨 𝗇 𝗍 . { 𝗉 𝗋 𝗂 𝗇 𝗍 = 𝗍 𝗈 𝖲 𝗍 𝗋 𝗂 𝗇 𝗀 x}) f := (λx : 𝖨 𝗇 𝗍 . { 𝖾 𝗏 𝖺 𝗅 = x}) Static ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ⇐ ⊳ Applicative distribution 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } & { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 } ( 𝖨 𝗇 𝗍 → { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 }) ( 𝖨 𝗇 𝗍 → { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }) & (A → B1) & (A → B2) <: A → B1 & B2 𝖨 𝗇 𝗍 ((1 + 1) , , 𝗍 𝗋 𝗎 𝖾 ) ⇒ 𝖨 𝗇 𝗍 & 𝖡 𝗈 𝗈 𝗅 𝖨 𝗇 𝗍 & 𝖡 𝗈 𝗈 𝗅 <: 𝖨 𝗇 𝗍 { 𝖾 𝗏 𝖺 𝗅 : 𝖨 𝗇 𝗍 } & { 𝗉 𝗋 𝗂 𝗇 𝗍 : 𝖲 𝗍 𝗋 }
  • 92. Thanks! More in the paper… 24 • Artifact • Algorithmic subtyping with polymorphic types • Enhanced subtyping and disjointness • More CP examples • Self-contained presentation of 𝖥 + i
  • 93. Thanks! More in the paper… 25 • Artifact • Algorithmic subtyping with polymorphic types • Enhanced subtyping and disjointness • More CP examples • Self-contained presentation of 𝖥 + i *Xuejing Huang, Jinxu Zhao, and Bruno C. d. S. Oliveira. Taming the merge operator. Journal of Functional Programming, 31:e28, 2021.
  • 94. Thanks! More in the paper… 25 • Artifact • Algorithmic subtyping with polymorphic types Based on splittable types* • Enhanced subtyping and disjointness • More CP examples • Self-contained presentation of 𝖥 + i *Xuejing Huang, Jinxu Zhao, and Bruno C. d. S. Oliveira. Taming the merge operator. Journal of Functional Programming, 31:e28, 2021.
  • 95. Thanks! More in the paper… 25 • Artifact • Algorithmic subtyping with polymorphic types Based on splittable types* • Enhanced subtyping and disjointness More types equivalent to Top • More CP examples • Self-contained presentation of 𝖥 + i *Xuejing Huang, Jinxu Zhao, and Bruno C. d. S. Oliveira. Taming the merge operator. Journal of Functional Programming, 31:e28, 2021.
  • 96. Thanks! More in the paper… 25 • Artifact is type sound, formalized in the Coq theorem prover 𝖥 + i • Algorithmic subtyping with polymorphic types Based on splittable types* • Enhanced subtyping and disjointness More types equivalent to Top • More CP examples • Self-contained presentation of 𝖥 + i A PureScript implementation of CP on top of 𝖥 + i *Xuejing Huang, Jinxu Zhao, and Bruno C. d. S. Oliveira. Taming the merge operator. Journal of Functional Programming, 31:e28, 2021.