@@ -575,6 +575,7 @@ data Vect : Set -> Nat -> Set where
575\end{SaveVerbatim}
575\end{SaveVerbatim}
576\useverb{listvec}
576\useverb{listvec}
578Note that the constructor names are the same for each --- constructor names (in
579Note that the constructor names are the same for each --- constructor names (in
579fact, names in general) can be overloaded, provided that they are declared in
580fact, names in general) can be overloaded, provided that they are declared in
580different namespaces (see Section \ref{sect:namespaces}), and will typically be
581different namespaces (see Section \ref{sect:namespaces}), and will typically be
@@ -586,6 +587,7 @@ names \texttt{Nil} and \texttt{::} can be written in list form. For example:
586\item \texttt{[1,2,3]} means \texttt{Cons 1 (Cons 2 (Cons 3 Nil))}
587\item \texttt{[1,2,3]} means \texttt{Cons 1 (Cons 2 (Cons 3 Nil))}
587\end{itemize}
588\end{itemize}
589The library also defines a number of functions for manipulating these types.
591The library also defines a number of functions for manipulating these types.
590\texttt{map} is overloaded both for \texttt{List} and \texttt{Vect}
592\texttt{map} is overloaded both for \texttt{List} and \texttt{Vect}
591and applies a function to every element of the list or vector.
593and applies a function to every element of the list or vector.
@@ -628,6 +630,7 @@ You'll find these examples in \texttt{usefultypes.idr} in the \texttt{examples/}
628\end{SaveVerbatim}
630\end{SaveVerbatim}
629\useverb{rundvect}
631\useverb{rundvect}
631For more details of the functions available on \texttt{List} and \texttt{Vect},
634For more details of the functions available on \texttt{List} and \texttt{Vect},
632look in the library, in \texttt{prelude/list.idr} and \texttt{prelude/vect.idr} respectively.
635look in the library, in \texttt{prelude/list.idr} and \texttt{prelude/vect.idr} respectively.
633Functions include filtering, appending, reversing, and so on. Also remember
636Functions include filtering, appending, reversing, and so on. Also remember
@@ -681,6 +684,7 @@ data Maybe a = Just a | Nothing;
681\end{SaveVerbatim}
684\end{SaveVerbatim}
682\useverb{maybe}
685\useverb{maybe}
684\texttt{Maybe} is one way of giving a type to an operation that may fail. For example,
688\texttt{Maybe} is one way of giving a type to an operation that may fail. For example,
685looking something up in a \texttt{List} (rather than a vector) may result in an out of
689looking something up in a \texttt{List} (rather than a vector) may result in an out of
686bounds error:
690bounds error:
@@ -695,6 +699,7 @@ list_lookup (S k) (x :: xs) = list_lookup k xs;
695\end{SaveVerbatim}
699\end{SaveVerbatim}
696\useverb{lookuplist}
700\useverb{lookuplist}
698The \texttt{maybe} function is used to process values of type \texttt{Maybe},
703The \texttt{maybe} function is used to process values of type \texttt{Maybe},
699either by applying a function to the value, if there is one, or by providing a default value:
704either by applying a function to the value, if there is one, or by providing a default value:
@@ -705,6 +710,7 @@ maybe : Maybe a -> |(default:b) -> (a -> b) -> b;
705\end{SaveVerbatim}
710\end{SaveVerbatim}
706\useverb{maybefn}
711\useverb{maybefn}
708The vertical bar $\mid$ before the default value is a laziness annotation. Normally
714The vertical bar $\mid$ before the default value is a laziness annotation. Normally
709expressions are evaluated before being passed to a function. This is typically
715expressions are evaluated before being passed to a function. This is typically
710the most efficient behaviour. However, in this case, the default value might
716the most efficient behaviour. However, in this case, the default value might
@@ -723,6 +729,7 @@ data Pair a b = MkPair a b;
723\end{SaveVerbatim}
729\end{SaveVerbatim}
724\useverb{mkpair}
730\useverb{mkpair}
726As syntactic sugar, we can write \texttt{(a, b)} which, according to context,
733As syntactic sugar, we can write \texttt{(a, b)} which, according to context,
727means either \texttt{Pair a b} or \texttt{MkPair a b}.
734means either \texttt{Pair a b} or \texttt{MkPair a b}.
728Tuples can contain an arbitrary number of values, represented as nested pairs:
735Tuples can contain an arbitrary number of values, represented as nested pairs:
@@ -751,6 +758,7 @@ data Exists : (A : Set) -> (P : A -> Set) -> Set where
751\end{SaveVerbatim}
758\end{SaveVerbatim}
752\useverb{sigma}
759\useverb{sigma}
754Again, there is syntactic sugar for this. \texttt{(a : A ** P)} is the type of a pair of
762Again, there is syntactic sugar for this. \texttt{(a : A ** P)} is the type of a pair of
755A and P, where the name \texttt{a} can occur inside P. \texttt{( a ** p (}
763A and P, where the name \texttt{a} can occur inside P. \texttt{( a ** p (}
756constructs a value of this type. For example, we can pair a number with a
764constructs a value of this type. For example, we can pair a number with a
@@ -790,6 +798,7 @@ vec = (_ ** [3, 4]);
790\end{SaveVerbatim}
798\end{SaveVerbatim}
791\useverb{dvec2}
799\useverb{dvec2}
793One use for dependent pairs is to return values of dependent types where the
802One use for dependent pairs is to return values of dependent types where the
794index is not necessarily known in advance. For example, if we filter elements
803index is not necessarily known in advance. For example, if we filter elements
795out of a \texttt{Vect} according to some predicate, we will not know in advance what the
804out of a \texttt{Vect} according to some predicate, we will not know in advance what the
@@ -812,6 +821,7 @@ vfilter p VNil = (_ , []);
812\end{SaveVerbatim}
821\end{SaveVerbatim}
813\useverb{vfilternil}
822\useverb{vfilternil}
815In the \texttt{::} case, we need to inspect the result of a recursive call to
825In the \texttt{::} case, we need to inspect the result of a recursive call to
816\texttt{filter} to
826\texttt{filter} to
817extract the length and the vector from the result. To do this, we use \texttt{with}
827extract the length and the vector from the result. To do this, we use \texttt{with}