comparison lib/top.ur @ 418:ad7e854a518c

Metaform demos, minus prose
author Adam Chlipala <adamc@hcoop.net>
date Thu, 23 Oct 2008 14:03:12 -0400
parents df4cbd90a26e
children 0ce90d4d9ae7
comparison
equal deleted inserted replaced
417:e0e9e9eca1cb 418:ad7e854a518c
33 fold [fn r :: {Unit} => $(mapUT tf r) -> tr r] 33 fold [fn r :: {Unit} => $(mapUT tf r) -> tr r]
34 (fn (nm :: Name) (t :: Unit) (rest :: {Unit}) acc 34 (fn (nm :: Name) (t :: Unit) (rest :: {Unit}) acc
35 [[nm] ~ rest] r => 35 [[nm] ~ rest] r =>
36 f [nm] [rest] r.nm (acc (r -- nm))) 36 f [nm] [rest] r.nm (acc (r -- nm)))
37 (fn _ => i) 37 (fn _ => i)
38
39 fun foldUR2 (tf1 :: Type) (tf2 :: Type) (tr :: {Unit} -> Type)
40 (f : nm :: Name -> rest :: {Unit}
41 -> fn [[nm] ~ rest] =>
42 tf1 -> tf2 -> tr rest -> tr ([nm] ++ rest))
43 (i : tr []) =
44 fold [fn r :: {Unit} => $(mapUT tf1 r) -> $(mapUT tf2 r) -> tr r]
45 (fn (nm :: Name) (t :: Unit) (rest :: {Unit}) acc
46 [[nm] ~ rest] r1 r2 =>
47 f [nm] [rest] r1.nm r2.nm (acc (r1 -- nm) (r2 -- nm)))
48 (fn _ _ => i)
49
50 fun foldURX2 (tf1 :: Type) (tf2 :: Type) (ctx :: {Unit})
51 (f : nm :: Name -> rest :: {Unit}
52 -> fn [[nm] ~ rest] =>
53 tf1 -> tf2 -> xml ctx [] []) =
54 foldUR2 [tf1] [tf2] [fn _ => xml ctx [] []]
55 (fn (nm :: Name) (rest :: {Unit}) [[nm] ~ rest] v1 v2 acc =>
56 <xml>{f [nm] [rest] v1 v2}{acc}</xml>)
57 <xml/>
38 58
39 fun foldTR (tf :: Type -> Type) (tr :: {Type} -> Type) 59 fun foldTR (tf :: Type -> Type) (tr :: {Type} -> Type)
40 (f : nm :: Name -> t :: Type -> rest :: {Type} 60 (f : nm :: Name -> t :: Type -> rest :: {Type}
41 -> fn [[nm] ~ rest] => 61 -> fn [[nm] ~ rest] =>
42 tf t -> tr rest -> tr ([nm = t] ++ rest)) 62 tf t -> tr rest -> tr ([nm = t] ++ rest))