summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2008-07-20 12:21:30 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2008-07-20 12:21:30 -0400
commit26a8eaaa3429aea2e455d18ff9a0f6c661d90cef (patch)
treed6b95ce4db9a809fbe365dfc157c8663c4b57b90
parent035e55c6c3d7d79a73f98e7d4c6a0e5e760c8cc8 (diff)
Form submission type-checking
-rw-r--r--lib/basis.lig4
-rw-r--r--src/lacweb.grm2
-rw-r--r--tests/form.lac9
3 files changed, 13 insertions, 2 deletions
diff --git a/lib/basis.lig b/lib/basis.lig
index 264427a0..3e3950cf 100644
--- a/lib/basis.lig
+++ b/lib/basis.lig
@@ -63,3 +63,7 @@ con lformTag = fn ty :: Type => fn attrs :: {Type} =>
-> 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 []
diff --git a/src/lacweb.grm b/src/lacweb.grm
index 0d2ab714..4fd3dc8e 100644
--- a/src/lacweb.grm
+++ b/src/lacweb.grm
@@ -285,7 +285,6 @@ eexp : eapps (eapps)
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 @@ eterm : LPAREN eexp RPAREN (#1 eexp, s (LPARENleft, RPARENright))
| 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)
diff --git a/tests/form.lac b/tests/form.lac
index 790dea2a..a046928a 100644
--- a/tests/form.lac
+++ b/tests/form.lac
@@ -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>