adamc@1004: con meta = fn (db :: Type, widget :: Type) => adamc@1004: {Nam : string, adamc@1004: Show : db -> xbody, adamc@1004: Widget : nm :: Name -> xml form [] [nm = widget], adamc@1004: WidgetPopulated : nm :: Name -> db -> xml form [] [nm = widget], adamc@1004: Parse : widget -> db, adamc@1004: Inject : sql_injectable db} adamc@1004: adamc@1004: fun default [t] (sh : show t) (rd : read t) (inj : sql_injectable t) name : meta (t, string) = adamc@1004: {Nam = name, adamc@1004: Show = txt, adamc@1004: Widget = fn [nm :: Name] => , adamc@1004: WidgetPopulated = fn [nm :: Name] n => adamc@1004: , adamc@1004: Parse = readError, adamc@1004: Inject = _} adamc@1004: adamc@1004: val int = default adamc@1004: val float = default adamc@1004: val string = default adamc@1004: fun bool name = {Nam = name, adamc@1004: Show = txt, adamc@1004: Widget = fn [nm :: Name] => , adamc@1004: WidgetPopulated = fn [nm :: Name] b => adamc@1004: , adamc@1004: Parse = fn x => x, adamc@1004: Inject = _} adamc@1007: adamc@1007: fun textarea name = {Nam = name, adamc@1007: Show = cdata, adamc@1007: Widget = fn [nm :: Name] => , adamc@1007: WidgetPopulated = fn [nm :: Name] s => adamc@1007: {[s]} adamc@1007: , adamc@1007: Parse = fn s => s, adamc@1007: Inject = _} adamc@1007: adamc@1009: fun allContent [ts ::: {(Type * Type)}] (r : $(map meta ts)) (vs : $(map fst ts)) (fl : folder ts) = adamc@1009: foldRX2 [meta] [fst] [_] adamc@1009: (fn [nm :: Name] [p :: (Type * Type)] [rest :: {(Type * Type)}] [[nm] ~ rest] adamc@1009: (m : meta p) v => adamc@1009: {[m.Nam]}: {m.Show v}) adamc@1009: [_] fl r vs adamc@1009: adamc@1007: fun allWidgets [ts ::: {(Type * Type)}] (r : $(map meta ts)) (fl : folder ts) = adamc@1007: foldR [meta] [fn ts :: {(Type * Type)} => xml form [] (map snd ts)] adamc@1007: (fn [nm :: Name] [t :: (Type * Type)] [rest :: {(Type * Type)}] adamc@1007: [[nm] ~ rest] (col : meta t) (acc : xml form [] (map snd rest)) => adamc@1007: {[col.Nam]}: {col.Widget [nm]} adamc@1007: {useMore acc} adamc@1007: ) adamc@1007: adamc@1007: [_] fl r adamc@1008: adamc@1011: fun allPopulated [ts ::: {(Type * Type)}] (r : $(map meta ts)) (vs : $(map fst ts)) (fl : folder ts) = adamc@1011: foldR2 [meta] [fst] [fn cols :: {(Type * Type)} => adamc@1011: xml form [] (map snd cols)] adamc@1011: (fn [nm :: Name] [p :: (Type * Type)] [rest :: {(Type * Type)}] [[nm] ~ rest] adamc@1011: (m : meta p) v (acc : xml form [] (map snd rest)) => adamc@1011: adamc@1011: {[m.Nam]}: {m.WidgetPopulated [nm] v} adamc@1011: {useMore acc} adamc@1011: ) adamc@1011: adamc@1011: [_] fl r vs adamc@1011: adamc@1008: fun allPopulatedTr [ts ::: {(Type * Type)}] (r : $(map meta ts)) (vs : $(map fst ts)) (fl : folder ts) = adamc@1008: foldR2 [meta] [fst] [fn cols :: {(Type * Type)} => adamc@1008: xml [Body, Form, Tr] [] (map snd cols)] adamc@1008: (fn [nm :: Name] [p :: (Type * Type)] [rest :: {(Type * Type)}] [[nm] ~ rest] adamc@1008: (m : meta p) v (acc : xml [Body, Form, Tr] [] (map snd rest)) => adamc@1008: adamc@1008: {m.WidgetPopulated [nm] v} adamc@1008: {useMore acc} adamc@1008: ) adamc@1008: adamc@1008: [_] fl r vs adamc@1008: adamc@1008: fun ensql [avail] [ts ::: {(Type * Type)}] (r : $(map meta ts)) (vs : $(map snd ts)) (fl : folder ts) = adamc@1008: map2 [meta] [snd] [fn ts :: (Type * Type) => sql_exp avail [] [] ts.1] adamc@1008: (fn [ts] meta v => @sql_inject meta.Inject (meta.Parse v)) adamc@1008: [_] fl r vs adamc@1030: adamc@1030: con private = fn t :: Type => adamc@1030: {Nam : string, adamc@1030: Initialize : t, adamc@1030: Show : t -> xbody, adamc@1030: Inject : sql_injectable t} adamc@1030: adamc@1030: fun initialize [ts] (r : $(map private ts)) (fl : folder ts) = adamc@1030: mp [private] [sql_exp [] [] []] (fn [t] r => @sql_inject r.Inject r.Initialize) [_] fl r