summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2014-05-02 17:16:02 -0400
committerGravatar Adam Chlipala <adam@chlipala.net>2014-05-02 17:16:02 -0400
commit8184fe8f3af43f4b614b79c411fc3b5578645983 (patch)
tree1249a913f37685611f686a4c5db3475723c93d21 /doc
parent4e164132ec8a73a440c2299126fc11c2275d439b (diff)
Monadic bind supports patterns
Diffstat (limited to 'doc')
-rw-r--r--doc/manual.tex2
1 files changed, 2 insertions, 0 deletions
diff --git a/doc/manual.tex b/doc/manual.tex
index 2a65c906..db4994a5 100644
--- a/doc/manual.tex
+++ b/doc/manual.tex
@@ -1442,6 +1442,8 @@ $$\begin{array}{l}
The Ur/Web compiler provides syntactic sugar for monads, similar to Haskell's \cd{do} notation. An expression $x \leftarrow e_1; e_2$ is desugared to $\mt{bind} \; e_1 \; (\lambda x \Rightarrow e_2)$, and an expression $e_1; e_2$ is desugared to $\mt{bind} \; e_1 \; (\lambda () \Rightarrow e_2)$. Note a difference from Haskell: as the $e_1; e_2$ case desugaring involves a function with $()$ as its formal argument, the type of $e_1$ must be of the form $m \; \{\}$, rather than some arbitrary $m \; t$.
+The syntactic sugar also allows $p \leftarrow e_1; e_2$ for $p$ a pattern. The pattern should be guaranteed to match any value of the corresponding type, or there will be a compile-time error.
+
\subsection{Transactions}
Ur is a pure language; we use Haskell's trick to support controlled side effects. The standard library defines a monad $\mt{transaction}$, meant to stand for actions that may be undone cleanly. By design, no other kinds of actions are supported.