From 66fa98fe9619afa56b10f1357edb617dc813051c Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Tue, 20 Oct 2009 10:29:17 -0400 Subject: Adapted existing demos to tuple pattern-matching --- demo/batchFun.ur | 12 ++++++------ demo/batchFun.urs | 12 ++++++------ demo/crud.ur | 15 +++++++-------- demo/crud.urs | 13 ++++++------- demo/more/grid.ur | 8 ++++---- demo/more/grid.urs | 6 +++--- demo/more/orm.ur | 14 +++++++------- demo/more/orm.urs | 12 ++++++------ 8 files changed, 45 insertions(+), 47 deletions(-) (limited to 'demo') diff --git a/demo/batchFun.ur b/demo/batchFun.ur index d88f11ca..c75cbb07 100644 --- a/demo/batchFun.ur +++ b/demo/batchFun.ur @@ -1,11 +1,11 @@ -con colMeta = fn t_state :: (Type * Type) => +con colMeta = fn (db :: Type, state :: Type) => {Nam : string, - Show : t_state.1 -> xbody, - Inject : sql_injectable t_state.1, + Show : db -> xbody, + Inject : sql_injectable db, - NewState : transaction t_state.2, - Widget : t_state.2 -> xbody, - ReadState : t_state.2 -> transaction t_state.1} + NewState : transaction state, + Widget : state -> xbody, + ReadState : state -> transaction db} con colsMeta = fn cols :: {(Type * Type)} => $(map colMeta cols) fun default [t] (sh : show t) (rd : read t) (inj : sql_injectable t) diff --git a/demo/batchFun.urs b/demo/batchFun.urs index e3acb197..56e1e88d 100644 --- a/demo/batchFun.urs +++ b/demo/batchFun.urs @@ -1,11 +1,11 @@ -con colMeta = fn t_state :: (Type * Type) => +con colMeta = fn (db :: Type, state :: Type) => {Nam : string, - Show : t_state.1 -> xbody, - Inject : sql_injectable t_state.1, + Show : db -> xbody, + Inject : sql_injectable db, - NewState : transaction t_state.2, - Widget : t_state.2 -> xbody, - ReadState : t_state.2 -> transaction t_state.1} + NewState : transaction state, + Widget : state -> xbody, + ReadState : state -> transaction db} con colsMeta = fn cols :: {(Type * Type)} => $(map colMeta cols) val int : string -> colMeta (int, source string) diff --git a/demo/crud.ur b/demo/crud.ur index 72523a9d..21c85d8f 100644 --- a/demo/crud.ur +++ b/demo/crud.ur @@ -1,11 +1,10 @@ -con colMeta = fn t_formT :: (Type * Type) => { - Nam : string, - Show : t_formT.1 -> xbody, - Widget : nm :: Name -> xml form [] [nm = t_formT.2], - WidgetPopulated : nm :: Name -> t_formT.1 -> xml form [] [nm = t_formT.2], - Parse : t_formT.2 -> t_formT.1, - Inject : sql_injectable t_formT.1 - } +con colMeta = fn (db :: Type, widget :: Type) => + {Nam : string, + Show : db -> xbody, + Widget : nm :: Name -> xml form [] [nm = widget], + WidgetPopulated : nm :: Name -> db -> xml form [] [nm = widget], + Parse : widget -> db, + Inject : sql_injectable db} con colsMeta = fn cols :: {(Type * Type)} => $(map colMeta cols) fun default [t] (sh : show t) (rd : read t) (inj : sql_injectable t) diff --git a/demo/crud.urs b/demo/crud.urs index 9b1055b2..3690d31e 100644 --- a/demo/crud.urs +++ b/demo/crud.urs @@ -1,11 +1,10 @@ -con colMeta = fn t_formT :: (Type * Type) => +con colMeta = fn (db :: Type, widget :: Type) => {Nam : string, - Show : t_formT.1 -> xbody, - Widget : nm :: Name -> xml form [] [nm = t_formT.2], - WidgetPopulated : nm :: Name -> t_formT.1 - -> xml form [] [nm = t_formT.2], - Parse : t_formT.2 -> t_formT.1, - Inject : sql_injectable t_formT.1} + Show : db -> xbody, + Widget : nm :: Name -> xml form [] [nm = widget], + WidgetPopulated : nm :: Name -> db -> xml form [] [nm = widget], + Parse : widget -> db, + Inject : sql_injectable db} con colsMeta = fn cols :: {(Type * Type)} => $(map colMeta cols) val int : string -> colMeta (int, string) diff --git a/demo/more/grid.ur b/demo/more/grid.ur index f2b9681c..170c6f2c 100644 --- a/demo/more/grid.ur +++ b/demo/more/grid.ur @@ -9,10 +9,10 @@ con colMeta' = fn (row :: Type) (input :: Type) (filter :: Type) => DisplayFilter : filter -> xbody, Filter : filter -> row -> signal bool, Sort : option (row -> row -> bool)} - -con colMeta = fn (row :: Type) (global_input_filter :: (Type * Type * Type)) => - {Initialize : transaction global_input_filter.1, - Handlers : global_input_filter.1 -> colMeta' row global_input_filter.2 global_input_filter.3} + +con colMeta = fn (row :: Type) (global :: Type, input :: Type, filter :: Type) => + {Initialize : transaction global, + Handlers : global -> colMeta' row input filter} con aggregateMeta = fn (row :: Type) (acc :: Type) => {Initial : acc, diff --git a/demo/more/grid.urs b/demo/more/grid.urs index a918c67b..e47e4139 100644 --- a/demo/more/grid.urs +++ b/demo/more/grid.urs @@ -10,9 +10,9 @@ con colMeta' = fn (row :: Type) (input :: Type) (filter :: Type) => Filter : filter -> row -> signal bool, Sort : option (row -> row -> bool)} -con colMeta = fn (row :: Type) (global_input_filter :: (Type * Type * Type)) => - {Initialize : transaction global_input_filter.1, - Handlers : global_input_filter.1 -> colMeta' row global_input_filter.2 global_input_filter.3} +con colMeta = fn (row :: Type) (global :: Type, input :: Type, filter :: Type) => + {Initialize : transaction global, + Handlers : global -> colMeta' row input filter} con aggregateMeta = fn (row :: Type) (acc :: Type) => {Initial : acc, diff --git a/demo/more/orm.ur b/demo/more/orm.ur index 24ccac67..620db9ad 100644 --- a/demo/more/orm.ur +++ b/demo/more/orm.ur @@ -1,9 +1,9 @@ con link = fn col_parent :: (Type * Type) => col_parent.1 -> transaction (option col_parent.2) fun noParent [t ::: Type] (_ : t) = return None -con meta = fn col_parent :: (Type * Type) => { - Link : link col_parent, - Inj : sql_injectable col_parent.1 +con meta = fn (col :: Type, parent :: Type) => { + Link : link (col, parent), + Inj : sql_injectable col } fun local [t :: Type] (inj : sql_injectable t) = {Link = noParent, @@ -55,10 +55,10 @@ functor Table(M : sig con col = fn t => {Exp : sql_exp [T = fs] [] [] t, Inj : sql_injectable t} val idCol = {Exp = sql_field [#T] [#Id], Inj = _} - con meta' = fn (fs :: {Type}) (col_parent :: (Type * Type)) => - {Col : {Exp : sql_exp [T = fs] [] [] col_parent.1, - Inj : sql_injectable col_parent.1}, - Parent : $fs -> transaction (option col_parent.2)} + con meta' = fn (fs :: {Type}) (col :: Type, parent :: Type) => + {Col : {Exp : sql_exp [T = fs] [] [] col, + Inj : sql_injectable col}, + Parent : $fs -> transaction (option parent)} val cols = foldR [meta] [fn before => after :: {(Type * Type)} -> [before ~ after] => $(map (meta' (map fst (before ++ after))) before)] (fn [nm :: Name] [ts :: (Type * Type)] [before :: {(Type * Type)}] diff --git a/demo/more/orm.urs b/demo/more/orm.urs index b173d203..63f4ffc9 100644 --- a/demo/more/orm.urs +++ b/demo/more/orm.urs @@ -1,9 +1,9 @@ con link :: (Type * Type) -> Type val noParent : t ::: Type -> link (t, unit) -con meta = fn col_parent :: (Type * Type) => { - Link : link col_parent, - Inj : sql_injectable col_parent.1 +con meta = fn (col :: Type, parent :: Type) => { + Link : link (col, parent), + Inj : sql_injectable col } val local : t :: Type -> sql_injectable t -> meta (t, unit) @@ -29,9 +29,9 @@ functor Table(M : sig con col :: Type -> Type val idCol : col id - val cols : $(map (fn col_parent :: (Type * Type) => - {Col : col col_parent.1, - Parent : row -> transaction (option col_parent.2)}) M.cols) + val cols : $(map (fn (colm :: Type, parent :: Type) => + {Col : col colm, + Parent : row -> transaction (option parent)}) M.cols) type filter val find : filter -> transaction (option row) -- cgit v1.2.3