haskell-lectures/VL2/content/VL2_polymorphism2.tex
2015-04-20 00:51:14 +02:00

20 lines
670 B
TeX

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
We can even have more generic stuff like:
\begin{haskellcode}
f :: a -> b
\end{haskellcode}
Whatever the function does... it has something of one type and returns something of another type (it could be the same type, but doesn't need to). That's all we know.
\vspace{\baselineskip}
\\
\pause
Similarly, remember the function \code{head} which gives us the first element of a list? The type signature actually looks like this:
\begin{haskellcode}
head :: [a] -> a
\end{haskellcode}
Makes sense?