@@ -109,6 +109,10 @@ e.g. (::). Infix operators can use any of the symbols:
109109\end{SaveVerbatim}
110110\useverb{infixsyms}
111111
112+\begin{SaveVerbatim}{argh}
113+$
114+\end{SaveVerbatim}
115+
112116\subsection{Functions}
113117
114118Functions are implemented by pattern matching, again using a similar syntax to
@@ -196,6 +200,34 @@ rev xs = revAcc [] xs where {
196200Any names which are visible in the outer scope are also visible in the \texttt{where}
197201clause (unless they have been redefined, such as \texttt{xs} here).
198202
203+\subsubsection*{\texttt{let} bindings}
204+
205+Intermediate values can be calculated using \texttt{let} bindings:
206+
207+\begin{SaveVerbatim}{letb}
208+
209+mirror : List a -> List a;
210+mirror xs = let xs' = rev xs in
211+ app xs xs';
212+
213+\end{SaveVerbatim}
214+\useverb{letb}
215+
216+\noindent
217+We can do simple pattern matching in \texttt{let} bindings too. For example, we can extract
218+fields from a record as follows, as well as by pattern matching at the top level:
219+
220+\begin{SaveVerbatim}{letp}
221+
222+data Person = MkPerson String Int;
223+
224+showPerson : Person -> String;
225+showPerson p = let MkPerson name age = p in
226+ name ++ " is " ++ show age ++ " years old";
227+
228+\end{SaveVerbatim}
229+\useverb{letp}
230+
199231\subsection{Dependent Types}
200232
201233\subsubsection{Vectors}
@@ -625,12 +657,13 @@ to use an anonymous function:
625657\end{SaveVerbatim}
626658\useverb{lam1}
627659
660+\noindent
628661The notation \texttt{$\backslash$x => val} constructs an anonymous function
629662which takes one argument, \texttt{x} and returns the expression \texttt{val}.
630663Anonymous functions may take several arguments, separated by commas, e.g.
631664\texttt{$\backslash$x, y, z => val}. Arguments may also be given explicit
632−types, e.g. \texttt{$\backslash$x : Int => x * 2}.
633−
665+types, e.g. \texttt{$\backslash$x : Int => x * 2}, and can pattern match,
666+e.g. \texttt{$\backslash$ (x, y) => x + y}.
634667We could also use an operator section:
635668
636669\begin{SaveVerbatim}{sec1}
@@ -641,6 +674,7 @@ We could also use an operator section:
641674\end{SaveVerbatim}
642675\useverb{sec1}
643676
677+\noindent
644678\texttt{(*2)} is shorthand for a function which multiplies a number by 2. It expands to
645679\texttt{$\backslash$x => x * 2}.
646680Similarly, \texttt{(2*)} would expand to \texttt{$\backslash$x => 2 * x}.