Reorder for improved clarity

This commit is contained in:
Julian Ospald 2015-04-16 01:31:15 +02:00
bovenliggende 8852f5d465
commit 81170661bc
Geen bekende sleutel gevonden voor deze handtekening in de database
GPG sleutel-ID: 220CD1C5BDEED020
1 gewijzigde bestanden met toevoegingen van 9 en 10 verwijderingen

19
VL1.tex
Bestand weergeven

@ -501,16 +501,6 @@ data MaybeInt = NoError Int
| Error String
\end{lstlisting}
\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:
\setHaskellCodeStyle
\begin{lstlisting}
@ -519,6 +509,15 @@ NoError :: Int -> MaybeInt
> :t Error
Error :: String -> MaybeInt
\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}
\begin{frame}[fragile]