From a609e91b959d905fc10554e97df153c09769ec90 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Tue, 24 Feb 2009 15:12:13 -0500 Subject: Demos compile again, with manual folders --- demo/crud.ur | 88 +++++++++++++++++++++++++++++++----------------------------- 1 file changed, 45 insertions(+), 43 deletions(-) (limited to 'demo/crud.ur') diff --git a/demo/crud.ur b/demo/crud.ur index b365f69b..a6a65bb3 100644 --- a/demo/crud.ur +++ b/demo/crud.ur @@ -33,6 +33,8 @@ fun bool name = {Nam = name, functor Make(M : sig con cols :: {(Type * Type)} constraint [Id] ~ cols + val fl : folder cols + val tab : sql_table ([Id = int] ++ map fstTT cols) val title : string @@ -50,12 +52,12 @@ functor Make(M : sig (fn (fs : {T : $([Id = int] ++ map fstTT M.cols)}) => {[fs.T.Id]} - {foldT2RX2 [fstTT] [colMeta] [tr] - (fn (nm :: Name) (t :: (Type * Type)) (rest :: {(Type * Type)}) - [[nm] ~ rest] v col => - {col.Show v} - ) - [M.cols] (fs.T -- #Id) M.cols} + {foldRX2 [fstTT] [colMeta] [tr] + (fn (nm :: Name) (t :: (Type * Type)) (rest :: {(Type * Type)}) + [[nm] ~ rest] v col => + {col.Show v} + ) + [M.cols] M.fl (fs.T -- #Id) M.cols} [Update] [Delete] @@ -66,12 +68,12 @@ functor Make(M : sig - {foldT2RX [colMeta] [tr] + {foldRX [colMeta] [tr] (fn (nm :: Name) (t :: (Type * Type)) (rest :: {(Type * Type)}) [[nm] ~ rest] col => ) - [M.cols] M.cols} + [M.cols] M.fl M.cols} {rows}
ID{cdata col.Nam}
@@ -79,14 +81,14 @@ functor Make(M : sig


- {foldT2R [colMeta] [fn cols :: {(Type * Type)} => xml form [] (map sndTT cols)] - (fn (nm :: Name) (t :: (Type * Type)) (rest :: {(Type * Type)}) - [[nm] ~ rest] (col : colMeta t) (acc : xml form [] (map sndTT rest)) => -
  • {cdata col.Nam}: {col.Widget [nm]}
  • - {useMore acc} -
    ) + {foldR [colMeta] [fn cols :: {(Type * Type)} => xml form [] (map sndTT cols)] + (fn (nm :: Name) (t :: (Type * Type)) (rest :: {(Type * Type)}) + [[nm] ~ rest] (col : colMeta t) (acc : xml form [] (map sndTT rest)) => +
  • {cdata col.Nam}: {col.Widget [nm]}
  • + {useMore acc} +
    ) - [M.cols] M.cols} + [M.cols] M.fl M.cols} @@ -95,13 +97,13 @@ functor Make(M : sig and create (inputs : $(map sndTT M.cols)) = id <- nextval seq; dml (insert tab - (foldT2R2 [sndTT] [colMeta] - [fn cols => $(map (fn t :: (Type * Type) => - sql_exp [] [] [] t.1) cols)] - (fn (nm :: Name) (t :: (Type * Type)) (rest :: {(Type * Type)}) - [[nm] ~ rest] => - fn input col acc => acc ++ {nm = @sql_inject col.Inject (col.Parse input)}) - {} [M.cols] inputs M.cols + (foldR2 [sndTT] [colMeta] + [fn cols => $(map (fn t :: (Type * Type) => + sql_exp [] [] [] t.1) cols)] + (fn (nm :: Name) (t :: (Type * Type)) (rest :: {(Type * Type)}) + [[nm] ~ rest] => + fn input col acc => acc ++ {nm = @sql_inject col.Inject (col.Parse input)}) + {} [M.cols] M.fl inputs M.cols ++ {Id = (SQL {[id]})})); ls <- list (); return @@ -113,17 +115,17 @@ functor Make(M : sig and upd (id : int) = let fun save (inputs : $(map sndTT M.cols)) = - dml (update [map fstTT M.cols] - (foldT2R2 [sndTT] [colMeta] - [fn cols => $(map (fn t :: (Type * Type) => - sql_exp [T = [Id = int] - ++ map fstTT M.cols] - [] [] t.1) cols)] - (fn (nm :: Name) (t :: (Type * Type)) (rest :: {(Type * Type)}) - [[nm] ~ rest] => - fn input col acc => acc ++ {nm = - @sql_inject col.Inject (col.Parse input)}) - {} [M.cols] inputs M.cols) + dml (update [map fstTT M.cols] ! + (foldR2 [sndTT] [colMeta] + [fn cols => $(map (fn t :: (Type * Type) => + sql_exp [T = [Id = int] + ++ map fstTT M.cols] + [] [] t.1) cols)] + (fn (nm :: Name) (t :: (Type * Type)) (rest :: {(Type * Type)}) + [[nm] ~ rest] => + fn input col acc => acc ++ {nm = + @sql_inject col.Inject (col.Parse input)}) + {} [M.cols] M.fl inputs M.cols) tab (WHERE T.Id = {[id]})); ls <- list (); return @@ -136,16 +138,16 @@ functor Make(M : sig case fso : (Basis.option {Tab : $(map fstTT M.cols)}) of None => return Not found! | Some fs => return
    - {foldT2R2 [fstTT] [colMeta] [fn cols :: {(Type * Type)} => xml form [] (map sndTT cols)] - (fn (nm :: Name) (t :: (Type * Type)) (rest :: {(Type * Type)}) - [[nm] ~ rest] (v : t.1) (col : colMeta t) - (acc : xml form [] (map sndTT rest)) => - -
  • {cdata col.Nam}: {col.WidgetPopulated [nm] v}
  • - {useMore acc} -
    ) - - [M.cols] fs.Tab M.cols} + {foldR2 [fstTT] [colMeta] [fn cols :: {(Type * Type)} => xml form [] (map sndTT cols)] + (fn (nm :: Name) (t :: (Type * Type)) (rest :: {(Type * Type)}) + [[nm] ~ rest] (v : t.1) (col : colMeta t) + (acc : xml form [] (map sndTT rest)) => + +
  • {cdata col.Nam}: {col.WidgetPopulated [nm] v}
  • + {useMore acc} +
    ) + + [M.cols] M.fl fs.Tab M.cols} -- cgit v1.2.3