aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-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