adamc@336: con colMeta' = fn t :: Type => {Nam : string, Show : t -> xbody} adamc@329: con colMeta = fn cols :: {Type} => $(Top.mapTT colMeta' cols) adamc@326: adamc@325: functor Make(M : sig adamc@325: con cols :: {Type} adamc@325: constraint [Id] ~ cols adamc@325: val tab : sql_table ([Id = int] ++ cols) adamc@325: adamc@325: val title : string adamc@325: adamc@327: val cols : colMeta cols adamc@325: end) = struct adamc@325: adamc@325: open constraints M adamc@325: val tab = M.tab adamc@325: adamc@337: fun delete (id : int) = adamc@337: () <- dml (DELETE FROM tab WHERE Id = {id}); adamc@337: return adamc@337: The deed is done. adamc@337: adamc@337: adamc@337: fun confirm (id : int) = return adamc@337:

Are you sure you want to delete ID #{txt _ id}?

adamc@337: adamc@337:

I was born sure!

adamc@337: adamc@337: adamc@334: fun main () : transaction page = adamc@334: rows <- queryX (SELECT * FROM tab AS T) adamc@334: (fn (fs : {T : $([Id = int] ++ M.cols)}) => adamc@326: adamc@326: {txt _ fs.T.Id} adamc@332: {foldTRX2 [idT] [colMeta'] [tr] adamc@329: (fn (nm :: Name) (t :: Type) (rest :: {Type}) => adamc@326: [[nm] ~ rest] => adamc@336: fn v col => adamc@336: {col.Show v} adamc@326: ) adamc@326: [M.cols] (fs.T -- #Id) M.cols} adamc@337: [Delete] adamc@326: adamc@334: ); adamc@325: return adamc@334: {cdata M.title} adamc@325: adamc@325: adamc@325: adamc@334:

{cdata M.title}

adamc@325: adamc@325: adamc@336: adamc@336: adamc@336: {foldTRX [colMeta'] [tr] adamc@336: (fn (nm :: Name) (t :: Type) (rest :: {Type}) => adamc@336: [[nm] ~ rest] => adamc@336: fn col => adamc@336: adamc@336: ) adamc@336: [M.cols] M.cols} adamc@336: adamc@325: {rows} adamc@325:
ID
{cdata col.Nam}
adamc@325: adamc@325: adamc@325: end