summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2014-06-11 14:22:47 -0400
committerGravatar Adam Chlipala <adam@chlipala.net>2014-06-11 14:22:47 -0400
commitb81169750193dfb71fb48764619f81dbac29c37d (patch)
tree4cbada553614a81254d7edee64f69969e7c8a46c
parentfa90e68cdf1bb11a89eaafca74e48e88abf7a6da (diff)
let..where..end
-rw-r--r--doc/manual.tex2
-rw-r--r--src/urweb.grm1
-rw-r--r--tests/letwhere.ur7
3 files changed, 10 insertions, 0 deletions
diff --git a/doc/manual.tex b/doc/manual.tex
index 7fd135fa..4a11430b 100644
--- a/doc/manual.tex
+++ b/doc/manual.tex
@@ -625,6 +625,8 @@ There are infix operator syntaxes for a number of functions defined in the $\mt{
A signature item $\mt{table} \; x : c$ is shorthand for $\mt{val} \; x : \mt{Basis}.\mt{sql\_table} \; c \; []$. $\mt{view} \; x : c$ is shorthand for $\mt{val} \; x : \mt{Basis}.\mt{sql\_view} \; c$, $\mt{sequence} \; x$ is short for $\mt{val} \; x : \mt{Basis}.\mt{sql\_sequence}$. $\mt{cookie} \; x : \tau$ is shorthand for $\mt{val} \; x : \mt{Basis}.\mt{http\_cookie} \; \tau$, and $\mt{style} \; x$ is shorthand for $\mt{val} \; x : \mt{Basis}.\mt{css\_class}$.
+It is possible to write a $\mt{let}$ expression with its constituents in reverse order, along the lines of Haskell's \cd{where}. An expression $\mt{let} \; e \; \mt{where} \; ed^* \; \mt{end}$ desugars to $\mt{let} \; ed^* \; \mt{in} \; e \; \mt{end}$.
+
\section{Static Semantics}
diff --git a/src/urweb.grm b/src/urweb.grm
index 157ecfac..4671569d 100644
--- a/src/urweb.grm
+++ b/src/urweb.grm
@@ -1456,6 +1456,7 @@ eterm : LPAREN eexp RPAREN (#1 eexp, s (LPARENleft, RPARENright))
| UNDER (EWild, s (UNDERleft, UNDERright))
| LET edecls IN eexp END (ELet (edecls, eexp), s (LETleft, ENDright))
+ | LET eexp WHERE edecls END (ELet (edecls, eexp), s (LETleft, ENDright))
| LBRACK RBRACK (EVar (["Basis"], "Nil", Infer), s (LBRACKleft, RBRACKright))
diff --git a/tests/letwhere.ur b/tests/letwhere.ur
new file mode 100644
index 00000000..8854f2aa
--- /dev/null
+++ b/tests/letwhere.ur
@@ -0,0 +1,7 @@
+fun main () : transaction page =
+ let
+ return <xml>Hi {[alice]} and {[bob]}!</xml>
+ where
+ val alice = "Alice"
+ val bob = "Bob"
+ end