adamc@326: con colMeta = fn cols :: {Type} => $(Top.mapTT (fn t => {Show : t -> xbody}) 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@326: val cols : $(Top.mapTT (fn t => {Show : t -> xbody}) cols)
adamc@325: end) = struct
adamc@325:
adamc@325: open constraints M
adamc@325: val tab = M.tab
adamc@325:
adamc@325: fun list () =
adamc@325: rows <- query (SELECT * FROM tab AS T)
adamc@325: (fn fs acc => return
adamc@326: {acc}
adamc@326:
adamc@326: {txt _ fs.T.Id} |
adamc@326: {fold [fn cols :: {Type} => $cols -> colMeta cols -> xtr]
adamc@326: (fn (nm :: Name) (t :: Type) (rest :: {Type}) acc =>
adamc@326: [[nm] ~ rest] =>
adamc@326: fn (r : $([nm = t] ++ rest)) cols =>
adamc@326:
adamc@326: {cols.nm.Show r.nm} |
adamc@326: {acc (r -- nm) (cols -- nm)}
adamc@326:
)
adamc@326: (fn _ _ =>
)
adamc@326: [M.cols] (fs.T -- #Id) M.cols}
adamc@326:
adamc@325: ) ;
adamc@325: return
adamc@325: List
adamc@325:
adamc@325:
adamc@325:
adamc@325: List
adamc@325:
adamc@325:
adamc@325: ID |
adamc@325: {rows}
adamc@325:
adamc@325:
adamc@325:
adamc@325: fun main () : transaction page = return
adamc@325: {cdata M.title}
adamc@325:
adamc@325: {cdata M.title}
adamc@325:
adamc@325: List all rows
adamc@325:
adamc@325:
adamc@325: end