Mercurial > urweb
comparison demo/more/conference.ur @ 1001:1d456a06ea4e
Add tuple pattern-matching at the constructor level
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Tue, 20 Oct 2009 10:19:00 -0400 |
parents | |
children | 61c30f0742d7 |
comparison
equal
deleted
inserted
replaced
1000:5d7e05b4a5c0 | 1001:1d456a06ea4e |
---|---|
1 con reviewMeta = fn (db :: Type, widget :: Type) => | |
2 {Show : db -> xbody, | |
3 Widget : nm :: Name -> xml form [] [nm = widget], | |
4 WidgetPopulated : nm :: Name -> db -> xml form [] [nm = widget], | |
5 Parse : widget -> db, | |
6 Inject : sql_injectable db} | |
7 | |
8 fun default [t] (sh : show t) (rd : read t) (inj : sql_injectable t) : reviewMeta (t, string) = | |
9 {Show = txt, | |
10 Widget = fn [nm :: Name] => <xml><textbox{nm}/></xml>, | |
11 WidgetPopulated = fn [nm :: Name] n => | |
12 <xml><textbox{nm} value={show n}/></xml>, | |
13 Parse = readError, | |
14 Inject = _} | |
15 | |
16 val int = default | |
17 val float = default | |
18 val string = default | |
19 val bool = {Show = txt, | |
20 Widget = fn [nm :: Name] => <xml><checkbox{nm}/></xml>, | |
21 WidgetPopulated = fn [nm :: Name] b => | |
22 <xml><checkbox{nm} checked={b}/></xml>, | |
23 Parse = fn x => x, | |
24 Inject = _} | |
25 | |
26 functor Make(M : sig | |
27 con review :: {(Type * Type)} | |
28 val review : $(map reviewMeta review) | |
29 end) = struct | |
30 | |
31 fun main () = return <xml/> | |
32 | |
33 end |