@@ -1,8 +1,8 @@
1\section{Miscellany}
1\section{Miscellany}
3In this section we discuss a variety of additional features: extensible syntax,
3In this section we discuss a variety of additional features: extensible syntax,
4−literate programming, and interfacing with external libraries through the
4+literate programming, interfacing with external libraries through the
5−foriegn function interface.
5+foriegn function interface, and the universe hierarchy.
7\input{syntax}
7\input{syntax}
@@ -132,6 +132,69 @@ This is made possible through the following directives:
132\item \texttt{\%obj "x.o"} --- link with the object file \texttt{x.o}.
132\item \texttt{\%obj "x.o"} --- link with the object file \texttt{x.o}.
133\end{itemize}
133\end{itemize}
135+\subsection{Cumulativity}
137+Since values can appear in types and \emph{vice versa}, it is natural that types themselves
138+have types. For example:
140+\begin{SaveVerbatim}{typetypes}
145+Vect : Set -> Nat -> Set
151+But what about the type of \texttt{Set}? If we ask \Idris{} it reports
153+\begin{SaveVerbatim}{setset}
162+It \emph{appears} that \texttt{Set} is its own type. This would lead to an inconsitency
163+due to Girard's paradox~\cite{girard-thesis}, so internally there is a \emph{hierarchy}
164+of types (or \emph{universes}):
166+\begin{SaveVerbatim}{sethierarchy}
168+Set : Set 1 : Set 2 : Set 3 : ...
171+\useverb{sethierarchy}
174+Universes are \emph{cumulative}, that is, if \texttt{x : Set n} we can also have that
175+\texttt{x : Set m}, as long as \texttt{n < m}.
176+The typechecker generates such universe
177+constraints and reports an error if any inconsistencies are found. Ordinarily, a
178+programmer does not need to worry about this, but it does prevent (contrived)
182+\begin{SaveVerbatim}{idid}
184+myid : (a : Set) -> a -> a
187+idid : (a : Set) -> a -> a
194+The application of \texttt{myid} to itself leads to a cycle in the universe hierarchy
195+--- \texttt{myid}'s first argument is a \texttt{Set}, which cannot be at a lower level
196+than required if it is applied to itself.
135%\subsection{Comparison}
198%\subsection{Comparison}
137%How does \Idris{} compare with other dependently typed languages and proof
200%How does \Idris{} compare with other dependently typed languages and proof