Mercurial > urweb
comparison lib/ur/top.ur @ 898:d1d0b18afd3d
Working on Grid; have gone from one dynamic table bizareness to another
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Sun, 19 Jul 2009 17:45:02 -0400 |
parents | d4e811beb8eb |
children | 7a4b026e45dd |
comparison
equal
deleted
inserted
replaced
897:2faf558b2d05 | 898:d1d0b18afd3d |
---|---|
49 end | 49 end |
50 | 50 |
51 | 51 |
52 fun not b = if b then False else True | 52 fun not b = if b then False else True |
53 | 53 |
54 con idT (t :: Type) = t | 54 con id = K ==> fn t :: K => t |
55 con record (t :: {Type}) = $t | 55 con record (t :: {Type}) = $t |
56 con fst = K1 ==> K2 ==> fn t :: (K1 * K2) => t.1 | 56 con fst = K1 ==> K2 ==> fn t :: (K1 * K2) => t.1 |
57 con snd = K1 ==> K2 ==> fn t :: (K1 * K2) => t.2 | 57 con snd = K1 ==> K2 ==> fn t :: (K1 * K2) => t.2 |
58 con fst3 = K1 ==> K2 ==> K3 ==> fn t :: (K1 * K2 * K3) => t.1 | 58 con fst3 = K1 ==> K2 ==> K3 ==> fn t :: (K1 * K2 * K3) => t.1 |
59 con snd3 = K1 ==> K2 ==> K3 ==> fn t :: (K1 * K2 * K3) => t.2 | 59 con snd3 = K1 ==> K2 ==> K3 ==> fn t :: (K1 * K2 * K3) => t.2 |
90 | v => Some v) | 90 | v => Some v) |
91 | 91 |
92 fun txt [t] [ctx ::: {Unit}] [use ::: {Type}] (_ : show t) (v : t) = | 92 fun txt [t] [ctx ::: {Unit}] [use ::: {Type}] (_ : show t) (v : t) = |
93 cdata (show v) | 93 cdata (show v) |
94 | 94 |
95 fun mp [K] [tf1 :: K -> Type] [tf2 :: K -> Type] (f : t ::: K -> tf1 t -> tf2 t) [r :: {K}] (fl : folder r) = | |
96 fl [fn r :: {K} => $(map tf1 r) -> $(map tf2 r)] | |
97 (fn [nm :: Name] [t :: K] [rest :: {K}] [[nm] ~ rest] acc r => | |
98 acc (r -- nm) ++ {nm = f r.nm}) | |
99 (fn _ => {}) | |
100 | |
101 fun map2 [K1] [K2] [tf1 :: K1 -> Type] [tf2 :: K2 -> Type] [tf :: K1 -> K2] | |
102 (f : t ::: K1 -> tf1 t -> tf2 (tf t)) [r :: {K1}] (fl : folder r) = | |
103 fl [fn r :: {K1} => $(map tf1 r) -> $(map tf2 (map tf r))] | |
104 (fn [nm :: Name] [t :: K1] [rest :: {K1}] [[nm] ~ rest] acc r => | |
105 acc (r -- nm) ++ {nm = f r.nm}) | |
106 (fn _ => {}) | |
107 | |
95 fun foldUR [tf :: Type] [tr :: {Unit} -> Type] | 108 fun foldUR [tf :: Type] [tr :: {Unit} -> Type] |
96 (f : nm :: Name -> rest :: {Unit} | 109 (f : nm :: Name -> rest :: {Unit} |
97 -> [[nm] ~ rest] => | 110 -> [[nm] ~ rest] => |
98 tf -> tr rest -> tr ([nm] ++ rest)) | 111 tf -> tr rest -> tr ([nm] ++ rest)) |
99 (i : tr []) [r :: {Unit}] (fl : folder r)= | 112 (i : tr []) [r :: {Unit}] (fl : folder r) = |
100 fl [fn r :: {Unit} => $(mapU tf r) -> tr r] | 113 fl [fn r :: {Unit} => $(mapU tf r) -> tr r] |
101 (fn [nm :: Name] [t :: Unit] [rest :: {Unit}] [[nm] ~ rest] acc r => | 114 (fn [nm :: Name] [t :: Unit] [rest :: {Unit}] [[nm] ~ rest] acc r => |
102 f [nm] [rest] ! r.nm (acc (r -- nm))) | 115 f [nm] [rest] ! r.nm (acc (r -- nm))) |
103 (fn _ => i) | 116 (fn _ => i) |
104 | 117 |