annotate incl.urs @ 22:8de201d70b91
Implement JSON typeclass for polymorphic variants.
author |
Edward Z. Yang <ezyang@mit.edu> |
date |
Wed, 02 May 2012 11:47:37 -0400 |
parents |
943410267fad |
children |
|
rev |
line source |
adam@5
|
1 (** A record inclusion predicate *)
|
adam@5
|
2
|
adam@5
|
3 con incl :: K --> {K} -> {K} -> Type
|
adam@5
|
4
|
adam@5
|
5 val incl : K --> r1 :: {K} -> r2 :: {K} -> [r1 ~ r2] => incl r1 (r1 ++ r2)
|
adam@5
|
6 val proj : r1 ::: {Type} -> r2 ::: {Type} -> incl r1 r2 -> $r2 -> $r1
|
adam@5
|
7
|
adam@5
|
8 val inv1 : K --> nm :: Name -> t :: K -> r :: {K} -> r' :: {K}
|
adam@5
|
9 -> [[nm] ~ r] =>
|
adam@5
|
10 f :: (Name -> K -> {K} -> Type)
|
adam@5
|
11 -> incl ([nm = t] ++ r) r'
|
adam@5
|
12 -> (nm :: Name -> t :: K -> r :: {K} -> [[nm] ~ r] => f nm t ([nm = t] ++ r))
|
adam@5
|
13 -> f nm t r'
|
adam@5
|
14 val inv2 : K --> nm :: Name -> t :: K -> r :: {K} -> r' :: {K}
|
adam@5
|
15 -> [[nm] ~ r] =>
|
adam@5
|
16 incl ([nm = t] ++ r) r' -> incl r r'
|
adam@5
|
17
|
adam@5
|
18 val fold : K --> tf :: ({K} -> Type) -> r ::: {K}
|
adam@5
|
19 -> (nm :: Name -> v :: K -> r' :: {K}
|
adam@5
|
20 -> [[nm] ~ r'] => incl ([nm = v] ++ r') r -> tf r' -> tf ([nm = v] ++ r'))
|
adam@5
|
21 -> tf []
|
adam@5
|
22 -> folder r -> tf r
|