20 рядки
1.3 KiB
TeX
20 рядки
1.3 KiB
TeX
\ifger{Und jetzt können wir sie nutzen:}{And now we are going to write functions to use it:}
|
|
\begin{haskellcode}
|
|
isListEmpty :: List t -> Bool
|
|
isListEmpty Emtpy = True
|
|
isListEmpty x = False
|
|
\end{haskellcode}
|
|
\pause
|
|
\ifger{Wir können sogar Funktionen schreiben wie:}{We can also have:}
|
|
\begin{haskellcode}
|
|
f :: a -> b
|
|
\end{haskellcode}
|
|
\ifger{D.h. was auch immer diese Funktion macht, sie bekommt etwas von einem Typ rein und gibt etwas von einem anderen Typ aus. \hinline{a} und \hinline{b} könnten vom selben Typ sein, müssen aber nicht! D.h. Funktionen dieser Art geben uns häufig mehr Freiheit. Mehr können wir über diese Funktion nicht sagen.}{So, whatever the function does... it gets something of one type and returns something of another type. \hinline{b} \emph{could} be the same type as \hinline{a} here, but it doesn't need to, so functions of this type often give us more freedom! That's all we know about this function.}
|
|
\vspace{\baselineskip}
|
|
\\
|
|
\pause
|
|
\ifger{Erinnern wir uns an die Funktion \hinline{head}. Wir können auf jeder Art von Liste mit ihr operieren. Die Typsignatur:}{Similarly, remember the function \hinline{head} which gives us the first element of a list? The type signature actually looks like this:}
|
|
\begin{haskellcode}
|
|
head :: [a] -> a
|
|
\end{haskellcode}
|
|
\ifger{Macht Sinn?}{Makes sense?} |