changeset 142:6f9e224692ec

Form submission type-checking
author Adam Chlipala <adamc@hcoop.net>
date Sun, 20 Jul 2008 12:21:30 -0400
parents 63c699450281
children 4b9c2bd6157c
files lib/basis.lig src/lacweb.grm tests/form.lac
diffstat 3 files changed, 13 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/lib/basis.lig	Sun Jul 20 11:33:23 2008 -0400
+++ b/lib/basis.lig	Sun Jul 20 12:21:30 2008 -0400
@@ -63,3 +63,7 @@
         -> nm :: Name -> unit
         -> tag attrs ([LForm] ++ ctx) [] [] [nm = ty]
 val textbox : lformTag string []
+
+val submit : ctx ::: {Unit} -> [LForm] ~ ctx
+        -> use ::: {Type} -> unit
+        -> tag [Action = $use -> page] ([LForm] ++ ctx) ([LForm] ++ ctx) use []
--- a/src/lacweb.grm	Sun Jul 20 11:33:23 2008 -0400
+++ b/src/lacweb.grm	Sun Jul 20 12:21:30 2008 -0400
@@ -285,7 +285,6 @@
                                          end)
 
        | LPAREN eexp RPAREN DCOLON cexp (EAnnot (eexp, cexp), s (LPARENleft, cexpright))
-       | eterm DOT ident                (EField (eterm, ident), s (etermleft, identright))
 
 eterm  : LPAREN eexp RPAREN             (#1 eexp, s (LPARENleft, RPARENright))
 
@@ -297,6 +296,7 @@
        | FLOAT                          (EPrim (Prim.Float FLOAT), s (FLOATleft, FLOATright))
        | STRING                         (EPrim (Prim.String STRING), s (STRINGleft, STRINGright))
 
+       | path DOT ident                 (EField ((EVar path, s (pathleft, pathright)), ident), s (pathleft, identright))
        | FOLD                           (EFold, s (FOLDleft, FOLDright))
 
        | XML_BEGIN xml XML_END          (xml)
--- a/tests/form.lac	Sun Jul 20 11:33:23 2008 -0400
+++ b/tests/form.lac	Sun Jul 20 12:21:30 2008 -0400
@@ -1,6 +1,13 @@
+val handler = fn r => <html><body>
+        <li> Name: {cdata r.Nam}</li>
+        <li> Word: {cdata r.Word}</li>
+</body></html>
+
 val main : unit -> page = fn () => <html><body>
         <lform>
                 Name: <textbox{#Nam} /><br/>
-                Color: <textbox{#Color} /><br/>
+                Word: <textbox{#Word} /><br/>
+
+                <submit action={handler}/>
         </lform>
 </body></html>