-
Notifications
You must be signed in to change notification settings - Fork 9
Addition of iso recursive types to System F omega
Michael Lazear edited this page Dec 6, 2019
·
7 revisions
Given a simple System F omega calculus:
Kinds (K, L) ::= *
| K => L
Types (T, U) ::= Unit
| X -- type variable
| T -> U -- type of functions
| forall X :: K. T -- universal type
| \X::K. T -- type abstraction
| T U -- type application
Terms (t, u) ::= unit
| x -- variable
| (\x: T. t) -- abstraction
| t u -- application
| \X::K. t -- term-level type abstraction
| t [T] -- term-level type application
Types (T, U) ::= ...
| μ X. T
Terms (t, u) ::= ...
| fold (mu X. T) t
| unfold (mu X. T) t
We can easily represent a NatList
as an iso-recursive type in this system:
type NatList = Cons (Nat, NatList) | Nil :: μ NatList. Cons (Nat, Var(0)) | Nil -- using de Bruijn indices
which would unfold into:
Cons (Nat, μ Cons(Nat, μ Cons (Nat, Var(0) | Nil)) | Nil
type List 'a = Cons ('a, List 'a) | Nil
The first pass is to represent this as a recursive type with a type operator:
μ List. \A :: *. Cons (A, List A) | Nil
If we apply a unfold first, we yield the following. We will have to repeatedly apply a type (say, Nat
)
ΛA :: *. Cons(A, μ List. \A :: *. Cons (A, List A) | Nil) | Nil
What if we represent this first as a type operator with a body that is a recursive type?
type List = ΛA::*. μ ListF. Cons(A, ListF) | Nil
μ ListF. Cons(Nat, ListF) | Nil
This works, but it won't work for a perfect tree
type Tree a = Leaf a | Tree (a, a)
type Tree = ΛA::*. μ TreeF. Leaf A | TreeF (A, A)
=> μ TreeF. Leaf Nat | TreeF (Nat, Nat)
- http://lists.seas.upenn.edu/pipermail/types-list/2011/001525.html
- http://lists.seas.upenn.edu/pipermail/types-list/2008/001183.html (spot on on the same problem, very useful links)
- https://mail.haskell.org/pipermail/haskell-cafe/2008-January/038580.html (Same poster as above)
- https://www.seas.upenn.edu/~sweirich/papers/lx/lxpaper.pdf (seems useful)
- http://flint.cs.yale.edu/flint/publications/collins02-ita-tr.pdf
- https://pdxscholar.library.pdx.edu/cgi/viewcontent.cgi?article=3088&context=open_access_etds (possibly the most useful)