comparison lib/ur/top.ur @ 643:aa2290c32ce2

Avoid any JavaScript when pages don't need it; update demo prose
author Adam Chlipala <adamc@hcoop.net>
date Tue, 10 Mar 2009 10:44:26 -0400
parents 24fd1edfcaa3
children fcf0bd3d1667
comparison
equal deleted inserted replaced
642:4a125bbc602d 643:aa2290c32ce2
53 con snd = K1 ==> K2 ==> fn t :: (K1 * K2) => t.2 53 con snd = K1 ==> K2 ==> fn t :: (K1 * K2) => t.2
54 con fst3 = K1 ==> K2 ==> K3 ==> fn t :: (K1 * K2 * K3) => t.1 54 con fst3 = K1 ==> K2 ==> K3 ==> fn t :: (K1 * K2 * K3) => t.1
55 con snd3 = K1 ==> K2 ==> K3 ==> fn t :: (K1 * K2 * K3) => t.2 55 con snd3 = K1 ==> K2 ==> K3 ==> fn t :: (K1 * K2 * K3) => t.2
56 con thd3 = K1 ==> K2 ==> K3 ==> fn t :: (K1 * K2 * K3) => t.3 56 con thd3 = K1 ==> K2 ==> K3 ==> fn t :: (K1 * K2 * K3) => t.3
57 57
58 con mapUT = fn f :: Type => map (fn _ :: Unit => f) 58 con mapU = K ==> fn f :: K => map (fn _ :: Unit => f)
59 59
60 con ex = fn tf :: (Type -> Type) => 60 con ex = fn tf :: (Type -> Type) =>
61 res ::: Type -> (choice :: Type -> tf choice -> res) -> res 61 res ::: Type -> (choice :: Type -> tf choice -> res) -> res
62 62
63 fun ex (tf :: (Type -> Type)) (choice :: Type) (body : tf choice) : ex tf = 63 fun ex (tf :: (Type -> Type)) (choice :: Type) (body : tf choice) : ex tf =
73 fun foldUR (tf :: Type) (tr :: {Unit} -> Type) 73 fun foldUR (tf :: Type) (tr :: {Unit} -> Type)
74 (f : nm :: Name -> rest :: {Unit} 74 (f : nm :: Name -> rest :: {Unit}
75 -> [[nm] ~ rest] => 75 -> [[nm] ~ rest] =>
76 tf -> tr rest -> tr ([nm] ++ rest)) 76 tf -> tr rest -> tr ([nm] ++ rest))
77 (i : tr []) (r :: {Unit}) (fold : folder r)= 77 (i : tr []) (r :: {Unit}) (fold : folder r)=
78 fold [fn r :: {Unit} => $(mapUT tf r) -> tr r] 78 fold [fn r :: {Unit} => $(mapU tf r) -> tr r]
79 (fn (nm :: Name) (t :: Unit) (rest :: {Unit}) acc 79 (fn (nm :: Name) (t :: Unit) (rest :: {Unit}) acc
80 [[nm] ~ rest] r => 80 [[nm] ~ rest] r =>
81 f [nm] [rest] ! r.nm (acc (r -- nm))) 81 f [nm] [rest] ! r.nm (acc (r -- nm)))
82 (fn _ => i) 82 (fn _ => i)
83 83
84 fun foldUR2 (tf1 :: Type) (tf2 :: Type) (tr :: {Unit} -> Type) 84 fun foldUR2 (tf1 :: Type) (tf2 :: Type) (tr :: {Unit} -> Type)
85 (f : nm :: Name -> rest :: {Unit} 85 (f : nm :: Name -> rest :: {Unit}
86 -> [[nm] ~ rest] => 86 -> [[nm] ~ rest] =>
87 tf1 -> tf2 -> tr rest -> tr ([nm] ++ rest)) 87 tf1 -> tf2 -> tr rest -> tr ([nm] ++ rest))
88 (i : tr []) (r :: {Unit}) (fold : folder r) = 88 (i : tr []) (r :: {Unit}) (fold : folder r) =
89 fold [fn r :: {Unit} => $(mapUT tf1 r) -> $(mapUT tf2 r) -> tr r] 89 fold [fn r :: {Unit} => $(mapU tf1 r) -> $(mapU tf2 r) -> tr r]
90 (fn (nm :: Name) (t :: Unit) (rest :: {Unit}) acc 90 (fn (nm :: Name) (t :: Unit) (rest :: {Unit}) acc
91 [[nm] ~ rest] r1 r2 => 91 [[nm] ~ rest] r1 r2 =>
92 f [nm] [rest] ! r1.nm r2.nm (acc (r1 -- nm) (r2 -- nm))) 92 f [nm] [rest] ! r1.nm r2.nm (acc (r1 -- nm) (r2 -- nm)))
93 (fn _ _ => i) 93 (fn _ _ => i)
94 94