From e4e1bf5221bd0cf68df2ba444425e5a0b9d50af1 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Thu, 26 Feb 2009 16:16:54 -0500 Subject: Kind-polymorphic [fst] and friends --- demo/crud.ur | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'demo/crud.ur') diff --git a/demo/crud.ur b/demo/crud.ur index a6a65bb3..dc9a5b7c 100644 --- a/demo/crud.ur +++ b/demo/crud.ur @@ -35,7 +35,7 @@ functor Make(M : sig constraint [Id] ~ cols val fl : folder cols - val tab : sql_table ([Id = int] ++ map fstTT cols) + val tab : sql_table ([Id = int] ++ map fst cols) val title : string @@ -49,10 +49,10 @@ functor Make(M : sig fun list () = rows <- queryX (SELECT * FROM tab AS T) - (fn (fs : {T : $([Id = int] ++ map fstTT M.cols)}) => + (fn (fs : {T : $([Id = int] ++ map fst M.cols)}) => {[fs.T.Id]} - {foldRX2 [fstTT] [colMeta] [tr] + {foldRX2 [fst] [colMeta] [tr] (fn (nm :: Name) (t :: (Type * Type)) (rest :: {(Type * Type)}) [[nm] ~ rest] v col => {col.Show v} @@ -81,9 +81,9 @@ functor Make(M : sig


- {foldR [colMeta] [fn cols :: {(Type * Type)} => xml form [] (map sndTT cols)] + {foldR [colMeta] [fn cols :: {(Type * Type)} => xml form [] (map snd cols)] (fn (nm :: Name) (t :: (Type * Type)) (rest :: {(Type * Type)}) - [[nm] ~ rest] (col : colMeta t) (acc : xml form [] (map sndTT rest)) => + [[nm] ~ rest] (col : colMeta t) (acc : xml form [] (map snd rest)) =>
  • {cdata col.Nam}: {col.Widget [nm]}
  • {useMore acc}
    ) @@ -94,10 +94,10 @@ functor Make(M : sig
    - and create (inputs : $(map sndTT M.cols)) = + and create (inputs : $(map snd M.cols)) = id <- nextval seq; dml (insert tab - (foldR2 [sndTT] [colMeta] + (foldR2 [snd] [colMeta] [fn cols => $(map (fn t :: (Type * Type) => sql_exp [] [] [] t.1) cols)] (fn (nm :: Name) (t :: (Type * Type)) (rest :: {(Type * Type)}) @@ -114,12 +114,12 @@ functor Make(M : sig and upd (id : int) = let - fun save (inputs : $(map sndTT M.cols)) = - dml (update [map fstTT M.cols] ! - (foldR2 [sndTT] [colMeta] + fun save (inputs : $(map snd M.cols)) = + dml (update [map fst M.cols] ! + (foldR2 [snd] [colMeta] [fn cols => $(map (fn t :: (Type * Type) => sql_exp [T = [Id = int] - ++ map fstTT M.cols] + ++ map fst M.cols] [] [] t.1) cols)] (fn (nm :: Name) (t :: (Type * Type)) (rest :: {(Type * Type)}) [[nm] ~ rest] => @@ -134,14 +134,14 @@ functor Make(M : sig {ls}
    in - fso <- oneOrNoRows (SELECT tab.{{map fstTT M.cols}} FROM tab WHERE tab.Id = {[id]}); - case fso : (Basis.option {Tab : $(map fstTT M.cols)}) of + fso <- oneOrNoRows (SELECT tab.{{map fst M.cols}} FROM tab WHERE tab.Id = {[id]}); + case fso : (Basis.option {Tab : $(map fst M.cols)}) of None => return Not found! | Some fs => return
    - {foldR2 [fstTT] [colMeta] [fn cols :: {(Type * Type)} => xml form [] (map sndTT cols)] + {foldR2 [fst] [colMeta] [fn cols :: {(Type * Type)} => xml form [] (map snd cols)] (fn (nm :: Name) (t :: (Type * Type)) (rest :: {(Type * Type)}) [[nm] ~ rest] (v : t.1) (col : colMeta t) - (acc : xml form [] (map sndTT rest)) => + (acc : xml form [] (map snd rest)) =>
  • {cdata col.Nam}: {col.WidgetPopulated [nm] v}
  • {useMore acc} -- cgit v1.2.3