Mercurial > urweb
diff lib/top.ur @ 411:06fcddcd20d3
Sum demo, minus inference of {Unit}s
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Tue, 21 Oct 2008 19:24:39 -0400 |
parents | 8084fa9216de |
children | df4cbd90a26e |
line wrap: on
line diff
--- a/lib/top.ur Tue Oct 21 18:44:52 2008 -0400 +++ b/lib/top.ur Tue Oct 21 19:24:39 2008 -0400 @@ -6,6 +6,9 @@ con mapTT (f :: Type -> Type) = fold (fn nm t acc [[nm] ~ acc] => [nm = f t] ++ acc) [] +con mapUT = fn f :: Type => fold (fn nm t acc [[nm] ~ acc] => + [nm = f] ++ acc) [] + con mapT2T (f :: (Type * Type) -> Type) = fold (fn nm t acc [[nm] ~ acc] => [nm = f t] ++ acc) [] @@ -22,6 +25,17 @@ fun txt (t ::: Type) (ctx ::: {Unit}) (use ::: {Type}) (sh : show t) (v : t) = cdata (@show sh v) +fun foldUR (tf :: Type) (tr :: {Unit} -> Type) + (f : nm :: Name -> rest :: {Unit} + -> fn [[nm] ~ rest] => + tf -> tr rest -> tr ([nm] ++ rest)) + (i : tr []) = + fold [fn r :: {Unit} => $(mapUT tf r) -> tr r] + (fn (nm :: Name) (t :: Unit) (rest :: {Unit}) (acc : $(mapUT tf rest) -> tr rest) + [[nm] ~ rest] (r : $([nm = tf] ++ mapUT tf rest)) => + f [nm] [rest] r.nm (acc (r -- nm))) + (fn _ => i) + fun foldTR (tf :: Type -> Type) (tr :: {Type} -> Type) (f : nm :: Name -> t :: Type -> rest :: {Type} -> fn [[nm] ~ rest] =>