Mercurial > urweb
comparison lib/ur/monad.ur @ 910:8e540df3294d
grid1 compiles but gets stuck in JS
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Tue, 25 Aug 2009 13:57:56 -0400 |
parents | 7a4b026e45dd |
children | 321a2d6feb40 |
comparison
equal
deleted
inserted
replaced
909:1d3f60e74ec7 | 910:8e540df3294d |
---|---|
32 acc' <- acc (r1 -- nm) (r2 -- nm); | 32 acc' <- acc (r1 -- nm) (r2 -- nm); |
33 f [nm] [t] [rest] ! r1.nm r2.nm acc') | 33 f [nm] [t] [rest] ! r1.nm r2.nm acc') |
34 (fn _ _ => return i) | 34 (fn _ _ => return i) |
35 [_] fl | 35 [_] fl |
36 | 36 |
37 fun foldR3 [K] [m] (_ : monad m) [tf1 :: K -> Type] [tf2 :: K -> Type] [tf3 :: K -> Type] [tr :: {K} -> Type] | |
38 (f : nm :: Name -> t :: K -> rest :: {K} | |
39 -> [[nm] ~ rest] => | |
40 tf1 t -> tf2 t -> tf3 t -> tr rest -> m (tr ([nm = t] ++ rest))) | |
41 (i : tr []) [r :: {K}] (fl : folder r) = | |
42 Top.fold [fn r :: {K} => $(map tf1 r) -> $(map tf2 r) -> $(map tf3 r) -> m (tr r)] | |
43 (fn [nm :: Name] [t :: K] [rest :: {K}] [[nm] ~ rest] | |
44 (acc : _ -> _ -> _ -> m (tr rest)) r1 r2 r3 => | |
45 acc' <- acc (r1 -- nm) (r2 -- nm) (r3 -- nm); | |
46 f [nm] [t] [rest] ! r1.nm r2.nm r3.nm acc') | |
47 (fn _ _ _ => return i) | |
48 [_] fl | |
49 | |
37 fun mapR [K] [m] (_ : monad m) [tf :: K -> Type] [tr :: K -> Type] | 50 fun mapR [K] [m] (_ : monad m) [tf :: K -> Type] [tr :: K -> Type] |
38 (f : nm :: Name -> t :: K -> tf t -> m (tr t)) = | 51 (f : nm :: Name -> t :: K -> tf t -> m (tr t)) = |
39 @@foldR [m] _ [tf] [fn r => $(map tr r)] | 52 @@foldR [m] _ [tf] [fn r => $(map tr r)] |
40 (fn [nm :: Name] [t :: K] [rest :: {K}] [[nm] ~ rest] (v : tf t) | 53 (fn [nm :: Name] [t :: K] [rest :: {K}] [[nm] ~ rest] (v : tf t) |
41 (acc : $(map tr rest)) => | 54 (acc : $(map tr rest)) => |