Commit f839df8c authored by Simon Marlow's avatar Simon Marlow
Browse files

replace exp^0 with infixexp in guards, and sync syntax appendix

parent 5d84e9fc
......@@ -781,9 +781,9 @@ alt -> pat @->@ exp [@where@ decls]
gdpat -> \hprime{guards} @->@ exp [ gdpat ]
\hprime{guards} -> \hprime{@|@ guard_1, ..., guard_n} & \hprime{(n>=1)}
\hprime{guard} -> \hprime{pat @<-@ exp^0} & (\hprime{\tr{pattern guard}})
\hprime{guard} -> \hprime{pat @<-@ infixexp} & (\hprime{\tr{pattern guard}})
| \hprime{@let@ decls} & (\hprime{\tr{local declaration}})
| exp^0 & (\tr{boolean guard})
| infixexp & (\tr{boolean guard})
@@@
\indexsyn{exp}%
\indexsyn{alts}%
......@@ -823,7 +823,7 @@ A {\em guard}\index{guard} has one of the following forms:
"p" is a
pattern (see Section~\ref{pattern-matching}) of type "t" and "e" is an
expression type "t"\footnote{Note that the syntax of a pattern guard is the same as that of a generator in a list comprehension.
The minor contextual difference is that, in a list comprehension, a pattern of type "t" goes with an expression of type "@[@t@]@".}.
The contextual difference is that, in a list comprehension, a pattern of type "t" goes with an expression of type "@[@t@]@".}.
They succeed if the expression "e" matches the pattern "p", and introduce the bindings of the pattern to the environment.
\item {\em boolean guards}\index{boolean guard} are arbitrary expressions of
type @Bool@. They succeed if the expression evaluates to @True@, and they do not introduce new names to the environment. A boolean guard, "g", is semantically equivalent to the pattern guard "@True <- @g".
......@@ -888,7 +888,7 @@ However, the phrase "@Bool -> a@" is syntactically valid as a type, and
parsers with limited lookahead may incorrectly commit to this choice, and hence
reject the program. Programmers are advised, therefore, to avoid guards that
end with a type signature --- indeed that is why a "guard" contains
an "exp^0" not an "exp".
an "infixexp" not an "exp".
\subsection{Do Expressions}
\index{do expression}
......
......@@ -552,9 +552,12 @@ funlhs -> var apat \{ apat \}
rhs -> @=@ exp [@where@ decls]
| gdrhs [@where@ decls]
gdrhs -> gd @=@ exp [gdrhs]
gdrhs -> guards @=@ exp [gdrhs]
gd -> @|@ exp^0
\hprime{guards} -> \hprime{@|@ guard_1, ..., guard_n} & \hprime{(n>=1)}
\hprime{guard} -> \hprime{pat @<-@ infixexp} & (\hprime{\tr{pattern guard}})
| \hprime{@let@ decls} & (\hprime{\tr{local declaration}})
| infixexp & (\tr{boolean guard})
@@@
\indexsyn{funlhs}%
\indexsyn{pat}%
......@@ -610,7 +613,7 @@ alt -> pat @->@ exp [@where@ decls]
| pat gdpat [@where@ decls]
| & (empty alternative)
gdpat -> gd @->@ exp [ gdpat ]
gdpat -> \hprime{guards} @->@ exp [ gdpat ]
stmts -> stmt_1 ... stmt_n exp [@;@] & (n>=0)
stmt -> exp @;@
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment