@@ -322,13 +322,14 @@ on user input:
322main : IO ()
322main : IO ()
323main = do putStr "Enter a number: "
323main = do putStr "Enter a number: "
324 x <- getLine
324 x <- getLine
325− print (interp [] fact (prim__strToInt x))
325+ print (interp [] fact (cast x))
327\end{SaveVerbatim}
327\end{SaveVerbatim}
328\useverb{factmain}
328\useverb{factmain}
331−Here, \texttt{prim\_\_strToInt} is a primitive function which converts a string to
331+Here, \texttt{cast} is an overloaded function which converts a value from one
332+type to another if possible. Here, it conversts a string to
332an integer, giving 0 if the input is invalid. An example run of this program
333an integer, giving 0 if the input is invalid. An example run of this program
333at the \Idris{} interactive environment is shown in Figure \ref{factrun}.
334at the \Idris{} interactive environment is shown in Figure \ref{factrun}.
@@ -350,3 +351,24 @@ Enter a number: 6
350\end{SaveVerbatim}
351\end{SaveVerbatim}
351\codefig{factrun}{Running the well-typed interpreter}
352\codefig{factrun}{Running the well-typed interpreter}
354+\subsubsection*{Aside: \texttt{cast}}
356+The prelude defines a type class \texttt{Cast} which allows conversion between
359+\begin{SaveVerbatim}{castclass}
368+It is a \emph{multi-parameter} type class, defining the source type and object
369+type of the cast. It must be possible for the type checker \remph{both}
370+parameters at the point where the cast is applied.
371+There are casts defined between all of the primitive types, as far as