From ed10a428abc7be47f8cce83db8dc64ac3cb6e84b Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Tue, 14 Oct 2008 17:18:59 -0400 Subject: Reusable column handlers for Crud --- tests/crud.ur | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'tests/crud.ur') diff --git a/tests/crud.ur b/tests/crud.ur index b22cb157..02405f78 100644 --- a/tests/crud.ur +++ b/tests/crud.ur @@ -8,6 +8,28 @@ con colMeta = fn t_formT :: (Type * Type) => { } con colsMeta = fn cols :: {(Type * Type)} => $(Top.mapT2T colMeta cols) +fun default (t ::: Type) (sh : show t) (rd : read t) (inj : sql_injectable t) + name : colMeta (t, string) = + {Nam = name, + Show = txt _, + Widget = fn nm :: Name => , + WidgetPopulated = fn (nm :: Name) n => + , + Parse = readError _, + Inject = _} + +val int = default _ _ _ +val float = default _ _ _ +val string = default _ _ _ + +fun bool name = {Nam = name, + Show = txt _, + Widget = fn nm :: Name => , + WidgetPopulated = fn (nm :: Name) b => + , + Parse = fn x => x, + Inject = _} + functor Make(M : sig con cols :: {(Type * Type)} constraint [Id] ~ cols -- cgit v1.2.3