@@ -166,23 +166,14 @@ Indentation is significant --- functions in the \texttt{where} block must be ind
166166further than the outer function.
167167
168168\textbf{Remark (scope):}
169−Any names which are visible in the outer scope are also visible in the \texttt{where}
170−clause (unless they have been redefined, such as \texttt{xs} here).
171−\emph{However}, names which appear in the type are \emph{not} automatically
172−in scope. In particular,
173−in the above example, the \texttt{a} in the top level type and the \texttt{a} in the
174−auxiliary definition \texttt{revAcc} are \emph{not} the same. If this is the required
175−behaviour, the \texttt{a} can be brought into scope as follows:
176−
177−\begin{SaveVerbatim}{revwhereb}
178−
179−reverse : List a -> List a
180−reverse {a} xs = revAcc [] xs where
181− revAcc : List a -> List a -> List a
182− ...
183−
184−\end{SaveVerbatim}
185−\useverb{revwhereb}
169+Any names which are visible in the outer scope are also visible in the
170+\texttt{where} clause (unless they are redefined in the \texttt{where} clause,
171+such as \texttt{xs} here). A name which appears only in the type will be in
172+scope in the \texttt{where} clause if it is a \remph{parameter} to one of the
173+types, i.e. it is fixed across the entire structure. In particular, this means
174+that the \texttt{a} in the definition of \texttt{reverse} above is the
175+\remph{same} \texttt{a} as in the definition of \texttt{revAcc}, as \texttt{a}
176+is a parameter of \texttt{List}.
186177
187178\subsubsection{Dependent Types}
188179
@@ -210,9 +201,11 @@ from the simple type declarations above. It resembles a Haskell GADT
210201declaration: it explicitly states the type
211202of the type constructor \tTC{Vect} --- it takes a type and a \tTC{Nat} as an
212203argument, where \tTC{Type} stands for the type of types. We say that \tTC{Vect}
213−is \emph{parameterised} by a type, and \emph{indexed} over \tTC{Nat}. Each
214−constructor targets a different part of the family of types. \tDC{Nil} can only
215−be used to construct vectors with zero length, and \tDC{::} to construct
204+is \emph{parameterised} by a type, and \emph{indexed} over \tTC{Nat}.
205+The distinction between parameters and indices is that a parameter is fixed
206+across an entire structure, whereas an index may vary.
207+Each constructor targets a different part of the family of types. \tDC{Nil} can
208+only be used to construct vectors with zero length, and \tDC{::} to construct
216209vectors with non-zero length. The type of \tDC{::} states explicitly that an element
217210of type \texttt{a} and a tail of type \texttt{Vect a k} (i.e., a vector of length \texttt{k})
218211combine to make a vector of length \texttt{S k}.
@@ -425,7 +418,7 @@ to a \texttt{String}:
425418
426419instance Show a => Show (Vect a n) where
427420 show xs = "[" ++ show' xs ++ "]" where
428− show' : Vect a n' -> String
421+ show' : Vect a n -> String
429422 show' Nil = ""
430423 show' (x :: Nil) = show x
431424 show' (x :: xs) = show x ++ ", " ++ show' xs
@@ -433,15 +426,16 @@ instance Show a => Show (Vect a n) where
433426\end{SaveVerbatim}
434427\useverb{showvec}
435428
436−\noindent
437−\textbf{Remark: } The type of the auxiliary function \texttt{show'} is
438−important. The type variables \texttt{a} and \texttt{n} which are part of the
439−instance declaration for \texttt{Show (Vect a n)} are fixed across the entire
440−instance declaration. As a result, \texttt{a} need not be constrained
441−again. Furthermore, it means that if \texttt{n} is used again in the type, it refers
442−to the (fixed) length of the outermost list \texttt{xs}. Therefore,
443−there is a different name for the length \texttt{n'} in \texttt{show'}.
429+%\noindent
430+%\textbf{Remark: } The type of the auxiliary function \texttt{show'} is
431+%important. The type variables \texttt{a} and \texttt{n} which are part of the
432+%instance declaration for \texttt{Show (Vect a n)} are fixed across the entire
433+%instance declaration. As a result, \texttt{a} need not be constrained
434+%again. Furthermore, it means that if \texttt{n} is used again in the type, it refers
435+%to the (fixed) length of the outermost list \texttt{xs}. Therefore,
436+%there is a different name for the length \texttt{n'} in \texttt{show'}.
444437
438+\noindent
445439Like Haskell type classes, default definitions can be given in the class declaration.
446440Otherwise, all methods must be given in an instance. For example, there is an
447441\texttt{Eq} class: