comparison demo/crud.ur @ 434:c471345f5165

Remove need for '() <-' notation
author Adam Chlipala <adamc@hcoop.net>
date Mon, 27 Oct 2008 08:27:45 -0400
parents 0767d7ad0c3a
children d4a81273d4b1
comparison
equal deleted inserted replaced
433:659c17441250 434:c471345f5165
92 </form> 92 </form>
93 </xml> 93 </xml>
94 94
95 and create (inputs : $(mapT2T sndTT M.cols)) = 95 and create (inputs : $(mapT2T sndTT M.cols)) =
96 id <- nextval seq; 96 id <- nextval seq;
97 () <- dml (insert tab 97 dml (insert tab
98 (foldT2R2 [sndTT] [colMeta] 98 (foldT2R2 [sndTT] [colMeta]
99 [fn cols => $(mapT2T (fn t :: (Type * Type) => 99 [fn cols => $(mapT2T (fn t :: (Type * Type) =>
100 sql_exp [] [] [] t.1) cols)] 100 sql_exp [] [] [] t.1) cols)]
101 (fn (nm :: Name) (t :: (Type * Type)) (rest :: {(Type * Type)}) 101 (fn (nm :: Name) (t :: (Type * Type)) (rest :: {(Type * Type)})
102 [[nm] ~ rest] => 102 [[nm] ~ rest] =>
103 fn input col acc => acc with nm = @sql_inject col.Inject (col.Parse input)) 103 fn input col acc => acc with nm = @sql_inject col.Inject (col.Parse input))
104 {} [M.cols] inputs M.cols 104 {} [M.cols] inputs M.cols
105 with #Id = (SQL {id}))); 105 with #Id = (SQL {id})));
106 ls <- list (); 106 ls <- list ();
107 return <xml><body> 107 return <xml><body>
108 <p>Inserted with ID {[id]}.</p> 108 <p>Inserted with ID {[id]}.</p>
109 109
110 {ls} 110 {ls}
111 </body></xml> 111 </body></xml>
112 112
113 and save (id : int) (inputs : $(mapT2T sndTT M.cols)) = 113 and save (id : int) (inputs : $(mapT2T sndTT M.cols)) =
114 () <- dml (update [mapT2T fstTT M.cols] 114 dml (update [mapT2T fstTT M.cols]
115 (foldT2R2 [sndTT] [colMeta] 115 (foldT2R2 [sndTT] [colMeta]
116 [fn cols => $(mapT2T (fn t :: (Type * Type) => 116 [fn cols => $(mapT2T (fn t :: (Type * Type) =>
117 sql_exp [T = [Id = int] 117 sql_exp [T = [Id = int]
118 ++ mapT2T fstTT M.cols] 118 ++ mapT2T fstTT M.cols]
119 [] [] t.1) cols)] 119 [] [] t.1) cols)]
120 (fn (nm :: Name) (t :: (Type * Type)) (rest :: {(Type * Type)}) 120 (fn (nm :: Name) (t :: (Type * Type)) (rest :: {(Type * Type)})
121 [[nm] ~ rest] => 121 [[nm] ~ rest] =>
122 fn input col acc => acc with nm = 122 fn input col acc => acc with nm =
123 @sql_inject col.Inject (col.Parse input)) 123 @sql_inject col.Inject (col.Parse input))
124 {} [M.cols] inputs M.cols) 124 {} [M.cols] inputs M.cols)
125 tab (WHERE T.Id = {id})); 125 tab (WHERE T.Id = {id}));
126 ls <- list (); 126 ls <- list ();
127 return <xml><body> 127 return <xml><body>
128 <p>Saved!</p> 128 <p>Saved!</p>
129 129
130 {ls} 130 {ls}
148 148
149 <submit action={save id}/> 149 <submit action={save id}/>
150 </form></body></xml> 150 </form></body></xml>
151 151
152 and delete (id : int) = 152 and delete (id : int) =
153 () <- dml (DELETE FROM tab WHERE Id = {id}); 153 dml (DELETE FROM tab WHERE Id = {id});
154 ls <- list (); 154 ls <- list ();
155 return <xml><body> 155 return <xml><body>
156 <p>The deed is done.</p> 156 <p>The deed is done.</p>
157 157
158 {ls} 158 {ls}