comparison demo/more/meta.ur @ 1004:a87495bcaeec

Start of user management
author Adam Chlipala <adamc@hcoop.net>
date Tue, 20 Oct 2009 12:48:53 -0400
parents
children d3af9e54c828
comparison
equal deleted inserted replaced
1003:61c30f0742d7 1004:a87495bcaeec
1 con meta = fn (db :: Type, widget :: Type) =>
2 {Nam : string,
3 Show : db -> xbody,
4 Widget : nm :: Name -> xml form [] [nm = widget],
5 WidgetPopulated : nm :: Name -> db -> xml form [] [nm = widget],
6 Parse : widget -> db,
7 Inject : sql_injectable db}
8
9 fun default [t] (sh : show t) (rd : read t) (inj : sql_injectable t) name : meta (t, string) =
10 {Nam = name,
11 Show = txt,
12 Widget = fn [nm :: Name] => <xml><textbox{nm}/></xml>,
13 WidgetPopulated = fn [nm :: Name] n =>
14 <xml><textbox{nm} value={show n}/></xml>,
15 Parse = readError,
16 Inject = _}
17
18 val int = default
19 val float = default
20 val string = default
21 fun bool name = {Nam = name,
22 Show = txt,
23 Widget = fn [nm :: Name] => <xml><checkbox{nm}/></xml>,
24 WidgetPopulated = fn [nm :: Name] b =>
25 <xml><checkbox{nm} checked={b}/></xml>,
26 Parse = fn x => x,
27 Inject = _}