![Page 1: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/1.jpg)
Kind Inference for Datatypes
Ningning Xie 1 Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira 1
POPL 2020
1The University of Hong Kong
2Bryn Mawr College
3Tweag I/O
1
![Page 2: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/2.jpg)
Datatypes 101
• A datatype declaration defines a type, and the shape of each of the elements.
data List a = Nil | Cons a (List a)
-- List :: ?→ ? type constructor
-- Nil :: ∀a . List a data constructor
-- Cons :: ∀a . a → List a → List a data constructor
• Kind inference.
List Int :: ? -- accepted
List Maybe :: ? -- rejected
-- Maybe :: ?→ ?
2
![Page 3: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/3.jpg)
Datatypes 101
• A datatype declaration defines a type, and the shape of each of the elements.
data List a = Nil | Cons a (List a)
-- List :: ?→ ? type constructor
-- Nil :: ∀a . List a data constructor
-- Cons :: ∀a . a → List a → List a data constructor
• Kind inference.
List Int :: ? -- accepted
List Maybe :: ? -- rejected
-- Maybe :: ?→ ?
2
![Page 4: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/4.jpg)
Many Extensions
, But...
Haskell, Idris, Coq, Agda, ...
• Polymorphic Kinds
• Dependent Types
• ...
data X :: ∀a (b :: ?→ ?). a b → ?
data Y :: ∀(c :: Maybe Bool). X c → ?
error: Couldn’t match kind ...
3
![Page 5: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/5.jpg)
Many Extensions, But...
Haskell, Idris, Coq, Agda, ...
• Polymorphic Kinds
• Dependent Types
• ...
data X :: ∀a (b :: ?→ ?). a b → ?
data Y :: ∀(c :: Maybe Bool). X c → ?
error: Couldn’t match kind ...
3
![Page 6: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/6.jpg)
Many Extensions, But...
Haskell, Idris, Coq, Agda, ...
• Polymorphic Kinds
• Dependent Types
• ...
data X :: ∀a (b :: ?→ ?). a b → ?
data Y :: ∀(c :: Maybe Bool). X c → ?
error: Couldn’t match kind ...
3
![Page 7: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/7.jpg)
Problem
• Which datatype declarations should be accepted?
• What kinds do accepted datatypes have?
4
![Page 8: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/8.jpg)
Problem
• Which datatype declarations should be accepted?
• What kinds do accepted datatypes have?
4
![Page 9: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/9.jpg)
Why It Is Interesting
• A declarative specification of datatypes guides programmers.
• An algorithm helps inform the design of principled inference algorithms for
datatypes.
5
![Page 10: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/10.jpg)
Why It Is Interesting
• A declarative specification of datatypes guides programmers.
• An algorithm helps inform the design of principled inference algorithms for
datatypes.
5
![Page 11: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/11.jpg)
Contributions
• Kind inference for Haskell98
The first formalization of Haskell98’s datatype declarations.
• Kind inference for modern Haskell
A type and kind language that is unified and dependently typed.
• Technical advances
Technical innovations important in the implementation of type-inference for dependent types.
6
![Page 12: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/12.jpg)
Kind Inference for Haskell98
![Page 13: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/13.jpg)
Language Features
kind κ ::= ? | κ1 → κ2
• Haskell98 supports mutual recursion.
data P a = MkP (Q a)
data Q a = MkQ (P a)
7
![Page 14: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/14.jpg)
Language Features
kind κ ::= ? | κ1 → κ2
• Haskell98 supports mutual recursion.
data P a = MkP (Q a)
data Q a = MkQ (P a)
7
![Page 15: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/15.jpg)
Language Features
data Tree a = Leaf | Fork (Tree a) (Tree a)
-- Tree :: ?→ ??
-- Tree :: (?→ ?)→ ??
-- ... (infinitely many incomparable kinds)
Prelude> :kind TreeTree :: ?
8
![Page 16: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/16.jpg)
Language Features
data Tree a = Leaf | Fork (Tree a) (Tree a)
-- Tree :: ?→ ??
-- Tree :: (?→ ?)→ ??
-- ... (infinitely many incomparable kinds)
Prelude> :kind TreeTree :: ?
8
![Page 17: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/17.jpg)
It is possible that some parts of an inferred kind may not
be fully determined by the corresponding definitions; in
such cases, a default of ? is assumed.
Haskell98 Report Sec.4.6
9
![Page 18: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/18.jpg)
Defaulting
data Tree a = Leaf | Fork (Tree a) (Tree a)
-- Tree :: ?→ ? winner!
10
![Page 19: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/19.jpg)
Defaulting
data Tree a = Leaf | Fork (Tree a) (Tree a)
-- Tree :: ?→ ? winner!
10
![Page 20: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/20.jpg)
Defaulting
data Tree a = Leaf | Fork (Tree a) (Tree a)
-- Tree :: ?→ ? winner!
data P1 a = MkP1 P2
data P2 = MkP2 (P1 Maybe)
10
![Page 21: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/21.jpg)
Defaulting
data Tree a = Leaf | Fork (Tree a) (Tree a)
-- Tree :: ?→ ? winner!
data P1 a = MkP1 P2
data P2 = MkP2 ( P1 Maybe)
10
![Page 22: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/22.jpg)
Defaulting
data Tree a = Leaf | Fork (Tree a) (Tree a)
-- Tree :: ?→ ? winner!
data P1 a = MkP1 P2
data P2 = MkP2 ( P1 Maybe)
mutual recursion
10
![Page 23: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/23.jpg)
Defaulting
data Tree a = Leaf | Fork (Tree a) (Tree a)
-- Tree :: ?→ ? winner!
data P1 a = MkP1 P2
data P2 = MkP2 (P1 Maybe)
mutual recursion
10
![Page 24: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/24.jpg)
Defaulting
data Tree a = Leaf | Fork (Tree a) (Tree a)
-- Tree :: ?→ ? winner!
data P1 a = MkP1 P2
data P2 = MkP2 (P1 Maybe)
mutual recursion
-- a :: ?→ ?
-- P1 :: (?→ ?)→ ?
-- P2 :: ?
10
![Page 25: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/25.jpg)
Defaulting
data Tree a = Leaf | Fork (Tree a) (Tree a)
-- Tree :: ?→ ? winner!
data P1 a = MkP1 P2
data P2 = MkP2 (P1 Maybe)
mutual recursion
-- a :: ?→ ?
-- P1 :: (?→ ?)→ ?
-- P2 :: ?
310
![Page 26: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/26.jpg)
Defaulting
data Tree a = Leaf | Fork (Tree a) (Tree a)
-- Tree :: ?→ ? winner!
data P1 a = MkP1 P2
data P2 = MkP2 (P1 Maybe)
mutual recursion
-- a :: ?→ ?
-- P1 :: (?→ ?)→ ?
-- P2 :: ?
3
data P1 a = MkP1 7P2data P2 = MkP2 (P1 Maybe)
10
![Page 27: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/27.jpg)
Defaulting
data Tree a = Leaf | Fork (Tree a) (Tree a)
-- Tree :: ?→ ? winner!
data P1 a = MkP1 P2
data P2 = MkP2 (P1 Maybe)
mutual recursion
-- a :: ?→ ?
-- P1 :: (?→ ?)→ ?
-- P2 :: ?
3
data P1 a = MkP1
data P2 = MkP2 (P1 Maybe)
10
![Page 28: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/28.jpg)
Defaulting
data Tree a = Leaf | Fork (Tree a) (Tree a)
-- Tree :: ?→ ? winner!
data P1 a = MkP1 P2
data P2 = MkP2 (P1 Maybe)
mutual recursion
-- a :: ?→ ?
-- P1 :: (?→ ?)→ ?
-- P2 :: ?
3
data P1 a = MkP1
data P2 = MkP2 (P1 Maybe)
no mutual recursion
10
![Page 29: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/29.jpg)
Defaulting
data Tree a = Leaf | Fork (Tree a) (Tree a)
-- Tree :: ?→ ? winner!
data P1 a = MkP1 P2
data P2 = MkP2 (P1 Maybe)
mutual recursion
-- a :: ?→ ?
-- P1 :: (?→ ?)→ ?
-- P2 :: ?
3
data P1 a = MkP1
no mutual recursion
defaulting a :: ?
data P2 = MkP2 (P1 Maybe)
10
![Page 30: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/30.jpg)
Defaulting
data Tree a = Leaf | Fork (Tree a) (Tree a)
-- Tree :: ?→ ? winner!
data P1 a = MkP1 P2
data P2 = MkP2 (P1 Maybe)
mutual recursion
-- a :: ?→ ?
-- P1 :: (?→ ?)→ ?
-- P2 :: ?
3
data P1 a = MkP1
no mutual recursion
defaulting a :: ?
data P2 = MkP2 (P1 Maybe)
10
![Page 31: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/31.jpg)
Defaulting
data Tree a = Leaf | Fork (Tree a) (Tree a)
-- Tree :: ?→ ? winner!
data P1 a = MkP1 P2
data P2 = MkP2 (P1 Maybe)
mutual recursion
-- a :: ?→ ?
-- P1 :: (?→ ?)→ ?
-- P2 :: ?
3
data P1 a = MkP1
no mutual recursion
defaulting a :: ?
data P2 = MkP2 (P1 Maybe)
10
![Page 32: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/32.jpg)
Defaulting
data Tree a = Leaf | Fork (Tree a) (Tree a)
-- Tree :: ?→ ? winner!
data P1 a = MkP1 P2
data P2 = MkP2 (P1 Maybe)
mutual recursion
-- a :: ?→ ?
-- P1 :: (?→ ?)→ ?
-- P2 :: ?
3
data P1 a = MkP1
-- P1 :: ?→ ?
no mutual recursion
defaulting a :: ?
data P2 = MkP2 (P1 Maybe)
10
![Page 33: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/33.jpg)
Defaulting
data Tree a = Leaf | Fork (Tree a) (Tree a)
-- Tree :: ?→ ? winner!
data P1 a = MkP1 P2
data P2 = MkP2 (P1 Maybe)
mutual recursion
-- a :: ?→ ?
-- P1 :: (?→ ?)→ ?
-- P2 :: ?
3
data P1 a = MkP1
-- P1 :: ?→ ?
no mutual recursion
defaulting a :: ?
data P2 = MkP2 (P1 Maybe)
10
![Page 34: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/34.jpg)
Defaulting
data Tree a = Leaf | Fork (Tree a) (Tree a)
-- Tree :: ?→ ? winner!
data P1 a = MkP1 P2
data P2 = MkP2 (P1 Maybe)
mutual recursion
-- a :: ?→ ?
-- P1 :: (?→ ?)→ ?
-- P2 :: ?
3
data P1 a = MkP1
-- P1 :: ?→ ?
no mutual recursion
defaulting a :: ?
data P2 = MkP2 (P1 Maybe)-- rejected
10
![Page 35: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/35.jpg)
Defaulting
data Tree a = Leaf | Fork (Tree a) (Tree a)
-- Tree :: ?→ ? winner!
data P1 a = MkP1 P2
data P2 = MkP2 (P1 Maybe)
mutual recursion
-- a :: ?→ ?
-- P1 :: (?→ ?)→ ?
-- P2 :: ?
3
data P1 a = MkP1
-- P1 :: ?→ ?
no mutual recursion
defaulting a :: ?
data P2 = MkP2 (P1 Maybe)-- rejected
710
![Page 36: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/36.jpg)
More about Haskell98
• A declarative specification of the datatype language.
• A sound algorithmic system using context extension approaches (Gundry et al.,
2010; Dunfield and Krishnaswami, 2013).
• Defaulting fits naturally in the approach.
• Consequences and design alternatives of defaulting.
• Restore completeness and principality by endowing the declarative system with
kind parameters (Garcia and Cimini, 2015).
11
![Page 37: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/37.jpg)
Kind Inference for Modern Haskell
![Page 38: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/38.jpg)
The Kind Language
kind, type σ, K ::= ∀a. σ | ∀a : κ. σ | τmono- τ, κ ::= ? | Int | a | T | τ1 τ2 | τ1 @τ2 |→
• Kind polymorphism
data Tree a = Leaf | Fork (Tree a) (Tree a)
• The type and kind language is unified, dependently typed
data D :: ∀( k :: ?) (a :: k ). Tree a → ?
• Visible kind application, lifted from visible type application (Eisenberg et al., 2016)
12
![Page 39: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/39.jpg)
The Kind Language
kind, type σ, K ::= ∀a. σ | ∀a : κ. σ | τmono- τ, κ ::= ? | Int | a | T | τ1 τ2 | τ1 @τ2 |→
• Kind polymorphism
data Tree a = Leaf | Fork (Tree a) (Tree a)
• The type and kind language is unified, dependently typed
data D :: ∀( k :: ?) (a :: k ). Tree a → ?
• Visible kind application, lifted from visible type application (Eisenberg et al., 2016)
12
![Page 40: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/40.jpg)
The Kind Language
kind, type σ, K ::= ∀a. σ | ∀a : κ. σ | τmono- τ, κ ::= ? | Int | a | T | τ1 τ2 | τ1 @τ2 |→
• Kind polymorphism
data Tree a = Leaf | Fork (Tree a) (Tree a)
-- Tree :: ∀k . k → ?
• The type and kind language is unified, dependently typed
data D :: ∀( k :: ?) (a :: k ). Tree a → ?
• Visible kind application, lifted from visible type application (Eisenberg et al., 2016)
12
![Page 41: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/41.jpg)
The Kind Language
kind, type σ, K ::= ∀a. σ | ∀a : κ. σ | τmono- τ, κ ::= ? | Int | a | T | τ1 τ2 | τ1 @τ2 |→
• Kind polymorphism
data Tree a = Leaf | Fork (Tree a) (Tree a)
-- Tree :: ∀k . k → ?
• The type and kind language is unified, dependently typed
data D :: ∀( k :: ?) (a :: k ). Tree a → ?
• Visible kind application, lifted from visible type application (Eisenberg et al., 2016)
12
![Page 42: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/42.jpg)
The Kind Language
kind, type σ, K ::= ∀a. σ | ∀a : κ. σ | τmono- τ, κ ::= ? | Int | a | T | τ1 τ2 | τ1 @τ2 |→
• Kind polymorphism
data Tree a = Leaf | Fork (Tree a) (Tree a)
-- Tree :: ∀k . k → ?
• The type and kind language is unified, dependently typed
data D :: ∀( k :: ?) (a :: k ). Tree a → ?
• Visible kind application, lifted from visible type application (Eisenberg et al., 2016)
12
![Page 43: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/43.jpg)
Language Features
kind, type σ, K ::= ∀a. σ | ∀a : κ. σ | τmono- τ, κ ::= ? | Int | a | T | τ1 τ2 | τ1 @τ2 |→
• Open kind signature: a kind signature can contain free variables.
data D :: Tree @ k a → ?
-- D :: ∀(k :: ?) (a :: k). Tree @k a → ?
• Polymorphic recursion.
• Existential quantification for data constructors.
13
![Page 44: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/44.jpg)
Language Features
kind, type σ, K ::= ∀a. σ | ∀a : κ. σ | τmono- τ, κ ::= ? | Int | a | T | τ1 τ2 | τ1 @τ2 |→
• Open kind signature: a kind signature can contain free variables.
data D :: Tree @ k a → ?
-- D :: ∀(k :: ?) (a :: k). Tree @k a → ?
• Polymorphic recursion.
• Existential quantification for data constructors.
13
![Page 45: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/45.jpg)
Language Features
kind, type σ, K ::= ∀a. σ | ∀a : κ. σ | τmono- τ, κ ::= ? | Int | a | T | τ1 τ2 | τ1 @τ2 |→
• Open kind signature: a kind signature can contain free variables.
data D :: Tree @ k a → ?
-- D :: ∀(k :: ?) (a :: k). Tree @k a → ?
• Polymorphic recursion.
• Existential quantification for data constructors.
13
![Page 46: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/46.jpg)
Language Features
kind, type σ, K ::= ∀a. σ | ∀a : κ. σ | τmono- τ, κ ::= ? | Int | a | T | τ1 τ2 | τ1 @τ2 |→
• Open kind signature: a kind signature can contain free variables.
data D :: Tree @ k a → ?
-- D :: ∀(k :: ?) (a :: k). Tree @k a → ?
• Polymorphic recursion.
• Existential quantification for data constructors.
13
![Page 47: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/47.jpg)
Language Features
kind, type σ, K ::= ∀a. σ | ∀a : κ. σ | τmono- τ, κ ::= ? | Int | a | T | τ1 τ2 | τ1 @τ2 |→
• Open kind signature: a kind signature can contain free variables.
data D :: Tree @ k a → ?
-- D :: ∀(k :: ?) (a :: k). Tree @k a → ?
• Polymorphic recursion.
• Existential quantification for data constructors.
13
![Page 48: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/48.jpg)
Language Features
kind, type σ, K ::= ∀a. σ | ∀a : κ. σ | τmono- τ, κ ::= ? | Int | a | T | τ1 τ2 | τ1 @τ2 |→
• Open kind signature: a kind signature can contain free variables.
data D :: Tree @ k a → ?
-- D :: ∀(k :: ?) (a :: k). Tree @k a → ?
• Polymorphic recursion.
• Existential quantification for data constructors.
Challenges!
13
![Page 49: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/49.jpg)
Challenge #1
In which order do we put free variables in the ordered type context before kinding?
data Q :: ∀(a :: ( f b )) (c :: k ). f c → ?
-- well-scoped:
f , b , k k̀ ∀(a :: (f b)) (c :: k). f c → ?
7
f , k , b k̀ ∀(a :: (f b)) (c :: k). f c → ?
7
k , b , f k̀ ∀(a :: (f b)) (c :: k). f c → ?
3
· · ·
f :: k → ?
b :: k
k :: ?
R We cannot know the dependency order before kinding.
14
![Page 50: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/50.jpg)
Challenge #1
In which order do we put free variables in the ordered type context before kinding?
data Q :: ∀(a :: ( f b )) (c :: k ). f c → ?
-- well-scoped:
f , b , k k̀ ∀(a :: (f b)) (c :: k). f c → ?
7
f , k , b k̀ ∀(a :: (f b)) (c :: k). f c → ?
7
k , b , f k̀ ∀(a :: (f b)) (c :: k). f c → ?
3
· · ·
f :: k → ?
b :: k
k :: ?
R We cannot know the dependency order before kinding.
14
![Page 51: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/51.jpg)
Challenge #1
In which order do we put free variables in the ordered type context before kinding?
data Q :: ∀(a :: ( f b )) (c :: k ). f c → ?
-- well-scoped:
f , b , k k̀ ∀(a :: (f b)) (c :: k). f c → ?
7
f , k , b k̀ ∀(a :: (f b)) (c :: k). f c → ?
7
k , b , f k̀ ∀(a :: (f b)) (c :: k). f c → ?
3
· · ·
f :: k → ?
b :: k
k :: ?
R We cannot know the dependency order before kinding.
14
![Page 52: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/52.jpg)
Challenge #1
In which order do we put free variables in the ordered type context before kinding?
data Q :: ∀(a :: ( f b )) (c :: k ). f c → ?
-- well-scoped:
f , b , k k̀ ∀(a :: (f b)) (c :: k). f c → ?
7
f , k , b k̀ ∀(a :: (f b)) (c :: k). f c → ?
7
k , b , f k̀ ∀(a :: (f b)) (c :: k). f c → ?
3
· · ·
f :: k → ?
b :: k
k :: ?
R We cannot know the dependency order before kinding.
14
![Page 53: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/53.jpg)
Challenge #1
In which order do we put free variables in the ordered type context before kinding?
data Q :: ∀(a :: ( f b )) (c :: k ). f c → ?
-- well-scoped:
f , b , k k̀ ∀(a :: (f b)) (c :: k). f c → ?
7
f , k , b k̀ ∀(a :: (f b)) (c :: k). f c → ?
7
k , b , f k̀ ∀(a :: (f b)) (c :: k). f c → ?
3
· · ·
f :: k → ?
b :: k
k :: ?
R We cannot know the dependency order before kinding.
14
![Page 54: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/54.jpg)
Challenge #1
In which order do we put free variables in the ordered type context before kinding?
data Q :: ∀(a :: ( f b )) (c :: k ). f c → ?
-- well-scoped:
f , b , k k̀ ∀(a :: (f b)) (c :: k). f c → ? 7
f , k , b k̀ ∀(a :: (f b)) (c :: k). f c → ? 7
k , b , f k̀ ∀(a :: (f b)) (c :: k). f c → ? 3
· · ·
f :: k → ?
b :: k
k :: ?
R We cannot know the dependency order before kinding.
14
![Page 55: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/55.jpg)
Challenge #1
In which order do we put free variables in the ordered type context before kinding?
data Q :: ∀(a :: ( f b )) (c :: k ). f c → ?
-- well-scoped:
f , b , k k̀ ∀(a :: (f b)) (c :: k). f c → ? 7
f , k , b k̀ ∀(a :: (f b)) (c :: k). f c → ? 7
k , b , f k̀ ∀(a :: (f b)) (c :: k). f c → ? 3
· · ·
f :: k → ?
b :: k
k :: ?
R We cannot know the dependency order before kinding.
14
![Page 56: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/56.jpg)
Our Solution
Local scopes, sets of variables that may be reordered.
∆,Θ ::= • | ∆, a : κ | ∆,T : K | ∆, {∆′} | ...
Moving judgment reorders local scopes.
∆1 ++mv ∆2 Θ
15
![Page 57: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/57.jpg)
Challenge #2
How to generalize unification variables?
Given
16
![Page 58: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/58.jpg)
Challenge #2
How to generalize unification variables? Given
SameKind :: ∀(k :: ?). k → k → ?
16
![Page 59: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/59.jpg)
Challenge #2
How to generalize unification variables? Given
SameKind :: ∀(k :: ?). k → k → ?
k 7→ β̂
β̂ :: ?
⇓ generalizes
data Q :: ∀( b :: ?) (a :: b ).
SameKind @b a a
k 7→ (c → ?)
a 7→ β̂ β̂ :: c
⇓ generalizes
data T2 :: ∀( b :: c) (c :: ?) (d :: c → ?).
SameKind @(c → ?) (T1 @c @b ) a
-- (b::c) ill-typed, c out of scope
16
![Page 60: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/60.jpg)
Challenge #2
How to generalize unification variables? Given
SameKind :: ∀(k :: ?). k → k → ?
data Q :: ∀a . SameKind a a
k 7→ β̂
β̂ :: ?
⇓ generalizes
data Q :: ∀( b :: ?) (a :: b ).
SameKind @b a a
k 7→ (c → ?)
a 7→ β̂ β̂ :: c
⇓ generalizes
data T2 :: ∀( b :: c) (c :: ?) (d :: c → ?).
SameKind @(c → ?) (T1 @c @b ) a
-- (b::c) ill-typed, c out of scope
16
![Page 61: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/61.jpg)
Challenge #2
How to generalize unification variables? Given
SameKind :: ∀(k :: ?). k → k → ?
data Q :: ∀(a :: β̂ ). SameKind a a
k 7→ β̂
β̂ :: ?
⇓ generalizes
data Q :: ∀( b :: ?) (a :: b ).
SameKind @b a a
k 7→ (c → ?)
a 7→ β̂ β̂ :: c
⇓ generalizes
data T2 :: ∀( b :: c) (c :: ?) (d :: c → ?).
SameKind @(c → ?) (T1 @c @b ) a
-- (b::c) ill-typed, c out of scope
16
![Page 62: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/62.jpg)
Challenge #2
How to generalize unification variables? Given
SameKind :: ∀( k :: ?). k → k → ?
data Q :: ∀(a :: β̂ ). SameKind a a
k 7→ β̂
β̂ :: ?
⇓ generalizes
data Q :: ∀( b :: ?) (a :: b ).
SameKind @b a a
k 7→ (c → ?)
a 7→ β̂ β̂ :: c
⇓ generalizes
data T2 :: ∀( b :: c) (c :: ?) (d :: c → ?).
SameKind @(c → ?) (T1 @c @b ) a
-- (b::c) ill-typed, c out of scope
16
![Page 63: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/63.jpg)
Challenge #2
How to generalize unification variables? Given
SameKind :: ∀( k :: ?). k → k → ?
data Q :: ∀(a :: β̂ ). SameKind a a
k 7→ β̂
β̂ :: ?
⇓ generalizes
data Q :: ∀( b :: ?) (a :: b ).
SameKind @b a a
k 7→ (c → ?)
a 7→ β̂ β̂ :: c
⇓ generalizes
data T2 :: ∀( b :: c) (c :: ?) (d :: c → ?).
SameKind @(c → ?) (T1 @c @b ) a
-- (b::c) ill-typed, c out of scope
16
![Page 64: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/64.jpg)
Challenge #2
How to generalize unification variables? Given
SameKind :: ∀(k :: ?). k → k → ?
data Q :: ∀(a :: β̂ ). SameKind a a
k 7→ β̂
β̂ :: ?
⇓ generalizes
data Q :: ∀( b :: ?) (a :: b ).
SameKind @b a a
k 7→ (c → ?)
a 7→ β̂ β̂ :: c
⇓ generalizes
data T2 :: ∀( b :: c) (c :: ?) (d :: c → ?).
SameKind @(c → ?) (T1 @c @b ) a
-- (b::c) ill-typed, c out of scope
16
![Page 65: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/65.jpg)
Challenge #2
How to generalize unification variables? Given
SameKind :: ∀(k :: ?). k → k → ?
data Q :: ∀(a :: β̂ ). SameKind a a
k 7→ β̂
β̂ :: ?
⇓ generalizes
data Q :: ∀( b :: ?) (a :: b ).
SameKind @b a a
data T1 :: ∀(f :: ?) (a :: f). f → ?
data T2 :: ∀(c :: ?) (d :: c → ?).
SameKind T1 d → ?
k 7→ (c → ?)
a 7→ β̂ β̂ :: c
⇓ generalizes
data T2 :: ∀( b :: c) (c :: ?) (d :: c → ?).
SameKind @(c → ?) (T1 @c @b ) a
-- (b::c) ill-typed, c out of scope
16
![Page 66: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/66.jpg)
Challenge #2
How to generalize unification variables? Given
SameKind :: ∀( k :: ?). k → k → ?
data Q :: ∀(a :: β̂ ). SameKind a a
k 7→ β̂
β̂ :: ?
⇓ generalizes
data Q :: ∀( b :: ?) (a :: b ).
SameKind @b a a
data T1 :: ∀(f :: ?) (a :: f). f → ?
data T2 :: ∀(c :: ?) (d :: c → ?).
SameKind T1 d → ?
k 7→ (c → ?)
a 7→ β̂ β̂ :: c
⇓ generalizes
data T2 :: ∀( b :: c) (c :: ?) (d :: c → ?).
SameKind @(c → ?) (T1 @c @b ) a
-- (b::c) ill-typed, c out of scope
16
![Page 67: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/67.jpg)
Challenge #2
How to generalize unification variables? Given
SameKind :: ∀(k :: ?). k → k → ?
data Q :: ∀(a :: β̂ ). SameKind a a
k 7→ β̂
β̂ :: ?
⇓ generalizes
data Q :: ∀( b :: ?) (a :: b ).
SameKind @b a a
data T1 :: ∀( f :: ?) (a :: f). f → ?
data T2 :: ∀(c :: ?) (d :: c → ?).
SameKind T1 d → ?
k 7→ (c → ?) f 7→ c
a 7→ β̂ β̂ :: c
⇓ generalizes
data T2 :: ∀( b :: c) (c :: ?) (d :: c → ?).
SameKind @(c → ?) (T1 @c @b ) a
-- (b::c) ill-typed, c out of scope
16
![Page 68: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/68.jpg)
Challenge #2
How to generalize unification variables? Given
SameKind :: ∀(k :: ?). k → k → ?
data Q :: ∀(a :: β̂ ). SameKind a a
k 7→ β̂
β̂ :: ?
⇓ generalizes
data Q :: ∀( b :: ?) (a :: b ).
SameKind @b a a
data T1 :: ∀(f :: ?) ( a :: f). f → ?
data T2 :: ∀(c :: ?) (d :: c → ?).
SameKind T1 d → ?
k 7→ (c → ?) f 7→ c
a 7→ β̂ β̂ :: c
⇓ generalizes
data T2 :: ∀( b :: c) (c :: ?) (d :: c → ?).
SameKind @(c → ?) (T1 @c @b ) a
-- (b::c) ill-typed, c out of scope
16
![Page 69: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/69.jpg)
Challenge #2
How to generalize unification variables? Given
SameKind :: ∀(k :: ?). k → k → ?
data Q :: ∀(a :: β̂ ). SameKind a a
k 7→ β̂
β̂ :: ?
⇓ generalizes
data Q :: ∀( b :: ?) (a :: b ).
SameKind @b a a
data T1 :: ∀(f :: ?) (a :: f). f → ?
data T2 :: ∀(c :: ?) (d :: c → ?).
SameKind T1 d → ?
k 7→ (c → ?) f 7→ c
a 7→ β̂ β̂ :: c
⇓ generalizes
data T2 :: ∀( b :: c) (c :: ?) (d :: c → ?).
SameKind @(c → ?) (T1 @c @b ) a
-- (b::c) ill-typed, c out of scope
16
![Page 70: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/70.jpg)
Challenge #2
How to generalize unification variables? Given
SameKind :: ∀(k :: ?). k → k → ?
data Q :: ∀(a :: β̂ ). SameKind a a
k 7→ β̂
β̂ :: ?
⇓ generalizes
data Q :: ∀( b :: ?) (a :: b ).
SameKind @b a a
data T1 :: ∀(f :: ?) (a :: f). f → ?
data T2 :: ∀(c :: ?) (d :: c → ?).
SameKind T1 d → ?
k 7→ (c → ?) f 7→ c
a 7→ β̂ β̂ :: c
⇓ generalizes
data T2 :: ∀( b :: c) (c :: ?) (d :: c → ?).
SameKind @(c → ?) (T1 @c @b ) a
-- (b::c) ill-typed, c out of scope
16
![Page 71: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/71.jpg)
Challenge #2
How to generalize unification variables? Given
SameKind :: ∀(k :: ?). k → k → ?
data Q :: ∀(a :: β̂ ). SameKind a a
k 7→ β̂
β̂ :: ?
⇓ generalizes
data Q :: ∀( b :: ?) (a :: b ).
SameKind @b a a
data T1 :: ∀(f :: ?) (a :: f). f → ?
data T2 :: ∀(c :: ?) (d :: c → ?).
SameKind T1 d → ?
k 7→ (c → ?) f 7→ c
a 7→ β̂ β̂ :: c
⇓ generalizes
data T2 :: ∀( b :: c) (c :: ?) (d :: c → ?).
SameKind @(c → ?) (T1 @c @b ) a
-- (b::c) ill-typed, c out of scope
R How to handle unsolved unification variables with
dependency on local variables?
16
![Page 72: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/72.jpg)
Our Solution
Reject it!
∀(a :: k). σ after kinding σ, no unsolved unification variables can depend on a .
data T1 :: ∀(f :: ?) (a :: f). f → ?
data T2 :: ∀(c :: ?) (d :: c → ?). SameKind T1 d → ?
k 7→ (c → ?)
f 7→ c
a 7→ β̂
β̂ :: c
7
An unification variable, after kinding σ, is either
• solved; or
• since it doesn’t depend on a , generalized outside a .
17
![Page 73: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/73.jpg)
Our Solution
Reject it! via Quantification Check.
∀(a :: k). σ after kinding σ, no unsolved unification variables can depend on a .
data T1 :: ∀(f :: ?) (a :: f). f → ?
data T2 :: ∀(c :: ?) (d :: c → ?). SameKind T1 d → ?
k 7→ (c → ?)
f 7→ c
a 7→ β̂
β̂ :: c
7
An unification variable, after kinding σ, is either
• solved; or
• since it doesn’t depend on a , generalized outside a .
17
![Page 74: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/74.jpg)
Our Solution
Reject it! via Quantification Check.
∀(a :: k). σ after kinding σ, no unsolved unification variables can depend on a .
data T1 :: ∀(f :: ?) (a :: f). f → ?
data T2 :: ∀(c :: ?) (d :: c → ?). SameKind T1 d → ?
k 7→ (c → ?)
f 7→ c
a 7→ β̂
β̂ :: c
7
An unification variable, after kinding σ, is either
• solved; or
• since it doesn’t depend on a , generalized outside a .
17
![Page 75: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/75.jpg)
Our Solution
Reject it! via Quantification Check.
∀(a :: k). σ after kinding σ, no unsolved unification variables can depend on a .
data T1 :: ∀(f :: ?) (a :: f). f → ?
data T2 :: ∀(c :: ?) (d :: c → ?). SameKind T1 d → ?
k 7→ (c → ?)
f 7→ c
a 7→ β̂
β̂ :: c
7
An unification variable, after kinding σ, is either
• solved; or
• since it doesn’t depend on a , generalized outside a .
17
![Page 76: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/76.jpg)
Our Solution
Reject it! via Quantification Check.
∀(a :: k). σ after kinding σ, no unsolved unification variables can depend on a .
data T1 :: ∀(f :: ?) (a :: f). f → ?
data T2 :: ∀(c :: ?) (d :: c → ?). SameKind T1 d → ?
k 7→ (c → ?)
f 7→ c
a 7→ β̂
β̂ :: c7
An unification variable, after kinding σ, is either
• solved; or
• since it doesn’t depend on a , generalized outside a .
17
![Page 77: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/77.jpg)
Our Solution
Reject it! via Quantification Check.
∀(a :: k). σ after kinding σ, no unsolved unification variables can depend on a .
data T1 :: ∀(f :: ?) (a :: f). f → ?
data T2 :: ∀(c :: ?) (d :: c → ?). SameKind T1 d → ?
k 7→ (c → ?)
f 7→ c
a 7→ β̂
β̂ :: c7
An unification variable, after kinding σ, is either
• solved; or
• since it doesn’t depend on a , generalized outside a .
17
![Page 78: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/78.jpg)
Challenge #3
Unification for a dependently typed language.
• First-order unification, for the algorithm to be guessing-free and
predicative (Vytiniotis et al., 2011).
• Coen (2004) considers first-order unification, but only soundness is proved.
• A higher-order unification algorithm for Coq (Ziliani and Sozeau, 2015) favors
syntactic equality by trying first-order unification. To our knowledge, they lack a
correctness proof.
18
![Page 79: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/79.jpg)
Challenge #3
Unification for a dependently typed language.
• First-order unification, for the algorithm to be guessing-free and
predicative (Vytiniotis et al., 2011).
• Coen (2004) considers first-order unification, but only soundness is proved.
• A higher-order unification algorithm for Coq (Ziliani and Sozeau, 2015) favors
syntactic equality by trying first-order unification. To our knowledge, they lack a
correctness proof.
18
![Page 80: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/80.jpg)
Challenge #3
Unification for a dependently typed language.
• First-order unification, for the algorithm to be guessing-free and
predicative (Vytiniotis et al., 2011).
• Coen (2004) considers first-order unification, but only soundness is proved.
• A higher-order unification algorithm for Coq (Ziliani and Sozeau, 2015) favors
syntactic equality by trying first-order unification. To our knowledge, they lack a
correctness proof.
18
![Page 81: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/81.jpg)
Challenge #3
Unification for a dependently typed language.
• First-order unification, for the algorithm to be guessing-free and
predicative (Vytiniotis et al., 2011).
• Coen (2004) considers first-order unification, but only soundness is proved.
• A higher-order unification algorithm for Coq (Ziliani and Sozeau, 2015) favors
syntactic equality by trying first-order unification. To our knowledge, they lack a
correctness proof.
18
![Page 82: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/82.jpg)
Unification
α̂ : κ1, β̂ : κ2 u α̂ ≈ β̂
¬ Try solving β̂ = α̂
May not be well-formed: κ1 may not match κ2.
® Try unifying κ1 ≈ κ2 first.
¯ Unifying a type recurs to its kind, how does it terminate?
° ? : ? axiom.
19
![Page 83: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/83.jpg)
Unification
α̂ : κ1, β̂ : κ2 u α̂ ≈ β̂
¬ Try solving β̂ = α̂
May not be well-formed: κ1 may not match κ2.
® Try unifying κ1 ≈ κ2 first.
¯ Unifying a type recurs to its kind, how does it terminate?
° ? : ? axiom.
19
![Page 84: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/84.jpg)
Unification
α̂ : κ1, β̂ : κ2 u α̂ ≈ β̂
¬ Try solving β̂ = α̂
May not be well-formed: κ1 may not match κ2.
® Try unifying κ1 ≈ κ2 first.
¯ Unifying a type recurs to its kind, how does it terminate?
° ? : ? axiom.
19
![Page 85: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/85.jpg)
Unification
α̂ : κ1, β̂ : κ2 u α̂ ≈ β̂
¬ Try solving β̂ = α̂
May not be well-formed: κ1 may not match κ2.
® Try unifying κ1 ≈ κ2 first.
¯ Unifying a type recurs to its kind, how does it terminate?
° ? : ? axiom.
19
![Page 86: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/86.jpg)
Unification
α̂ : κ1, β̂ : κ2 u α̂ ≈ β̂
¬ Try solving β̂ = α̂
May not be well-formed: κ1 may not match κ2.
® Try unifying κ1 ≈ κ2 first.
¯ Unifying a type recurs to its kind, how does it terminate?
° ? : ? axiom.
19
![Page 87: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/87.jpg)
Unification
α̂ : κ1, β̂ : κ2 u α̂ ≈ β̂
¬ Try solving β̂ = α̂
May not be well-formed: κ1 may not match κ2.
® Try unifying κ1 ≈ κ2 first.
¯ Unifying a type recurs to its kind, how does it terminate?
° ? : ? axiom.
19
![Page 88: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/88.jpg)
Our Solution
Dependency graph visualizes the dependency information in an ordered context.
∆ = α̂ : ?, α̂1 : ?, α̂2 : ? = α̂1, α̂3 : ? → α̂2
?→ Int
α̂1 α̂
α̂3
3 We proved unification terminates.
20
![Page 89: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/89.jpg)
Our Solution
Dependency graph visualizes the dependency information in an ordered context.
∆ = α̂ : ?, α̂1 : ?, α̂2 : ? = α̂1, α̂3 : ? → α̂2
?→ Int
α̂1 α̂
α̂3
3 We proved unification terminates.
20
![Page 90: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/90.jpg)
More about modern Haskell
• A declarative specification of the datatype language.
• A sound algorithmic system.
Principality: our algorithm does not infer every kind acceptable by the declarative system, but the
kinds it does infer are always the best (principal) one (Vytiniotis et al., 2011).
• Discussion of language extensions.
Higher-rank polymorphism, GADTs, type families, visible dependent quantification, datatype
promotion, partial type signature.
21
![Page 91: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/91.jpg)
Summary
![Page 92: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/92.jpg)
Conclusion
We have presented the first known, detailed account of kind
inference for datatypes, both for Haskell98 and the Haskell
of today.
22
![Page 93: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/93.jpg)
Haskell and GHC
¬ Goal: produce a sound and complete pair of specification and
algorithm.
23
![Page 94: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/94.jpg)
Haskell and GHC
Detailed comparison with GHC included in our technical
supplement (Xie et al., 2019).
23
![Page 95: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/95.jpg)
Haskell and GHC
® Identified ways GHC can improve.
23
![Page 96: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/96.jpg)
Haskell and GHC
® Identified ways GHC can improve.
unexpected semantics =⇒ quantification check
23
![Page 97: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/97.jpg)
Beyond Haskell
· · ·
Inform the design of principled inference algorithms
for languages beyond Haskell.
24
![Page 98: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/98.jpg)
Kind Inference for Datatypes
Ningning Xie 1 Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira 1
POPL 2020
1The University of Hong Kong
2Bryn Mawr College
3Tweag I/O
25
![Page 99: Kind Inference for Datatypes - GitHub Pages · Kind Inference for Datatypes Ningning Xie 1Richard A. Eisenberg 2,3 Bruno C. d. S. Oliveira POPL 2020 1The University of Hong Kong 2Bryn](https://reader034.vdocuments.us/reader034/viewer/2022043000/5f77100ef17d09465612d1af/html5/thumbnails/99.jpg)
References
Claudio Sacerdoti Coen. 2004. Mathematical knowledge management and interactive theorem proving. Ph.D. Dissertation. University of Bologna,
2004. Technical Report UBLCS 2004-5.
Joshua Dunfield and Neelakantan R. Krishnaswami. 2013. Complete and easy bidirectional typechecking for higher-rank polymorphism. In ICFP’13.
14.
Richard A Eisenberg, Stephanie Weirich, and Hamidhasan G Ahmed. 2016. Visible type application. In ESOP’16.
Ronald Garcia and Matteo Cimini. 2015. Principal type schemes for gradual programs. In POPL’15. 13.
Adam Gundry, Conor McBride, and James McKinna. 2010. Type inference in context. In MSFP.
Dimitrios Vytiniotis, Simon Peyton Jones, Tom Schrijvers, and Martin Sulzmann. 2011. OutsideIn (X) Modular type inference with local assumptions.
JFP 21, 4-5 (2011), 333–412.
Ningning Xie, Richard A. Eisenberg, and Bruno C. d. S. Oliveira. 2019. Kind Inference for Datatypes: Technical Supplement. (Nov. 2019).
arXiv:1911.06153.
Beta Ziliani and Matthieu Sozeau. 2015. A Unification Algorithm for Coq Featuring Universe Polymorphism and Overloading. In ICFP’15.
26