diff demo/more/orm.ur @ 1002:bb3fc575cfe7

Adapted existing demos to tuple pattern-matching
author Adam Chlipala <adamc@hcoop.net>
date Tue, 20 Oct 2009 10:29:17 -0400
parents b132f8620a66
children 8d3aa6c7cee0
line wrap: on
line diff
--- a/demo/more/orm.ur	Tue Oct 20 10:19:00 2009 -0400
+++ b/demo/more/orm.ur	Tue Oct 20 10:29:17 2009 -0400
@@ -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 @@
     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)}]