Reorder for improved clarity
This commit is contained in:
parent
8852f5d465
commit
81170661bc
19
VL1.tex
19
VL1.tex
@ -501,16 +501,6 @@ data MaybeInt = NoError Int
|
|||||||
| Error String
|
| Error String
|
||||||
\end{lstlisting}
|
\end{lstlisting}
|
||||||
\pause
|
\pause
|
||||||
And now we can do sanity checks:
|
|
||||||
\pause
|
|
||||||
\setHaskellCodeStyle
|
|
||||||
\begin{lstlisting}
|
|
||||||
calcSomething :: Int -> MaybeInt
|
|
||||||
calcSomething x
|
|
||||||
| x < 100 = NoError (x * 5)
|
|
||||||
| otherwise = Error "Int out of range!"
|
|
||||||
\end{lstlisting}
|
|
||||||
\pause
|
|
||||||
So constructors are just \emph{functions}! And they can have arguments, just like functions. Let's check their types:
|
So constructors are just \emph{functions}! And they can have arguments, just like functions. Let's check their types:
|
||||||
\setHaskellCodeStyle
|
\setHaskellCodeStyle
|
||||||
\begin{lstlisting}
|
\begin{lstlisting}
|
||||||
@ -519,6 +509,15 @@ NoError :: Int -> MaybeInt
|
|||||||
> :t Error
|
> :t Error
|
||||||
Error :: String -> MaybeInt
|
Error :: String -> MaybeInt
|
||||||
\end{lstlisting}
|
\end{lstlisting}
|
||||||
|
\pause
|
||||||
|
And now we can do sanity checks:
|
||||||
|
\setHaskellCodeStyle
|
||||||
|
\begin{lstlisting}
|
||||||
|
calcSomething :: Int -> MaybeInt
|
||||||
|
calcSomething x
|
||||||
|
| x < 100 = NoError (x * 5)
|
||||||
|
| otherwise = Error "Int out of range!"
|
||||||
|
\end{lstlisting}
|
||||||
\end{frame}
|
\end{frame}
|
||||||
|
|
||||||
\begin{frame}[fragile]
|
\begin{frame}[fragile]
|
||||||
|
Loading…
Reference in New Issue
Block a user