haskell-lectures/VL2/content/VL2_polymorphism2.tex

20 lines
670 B
TeX
Raw Normal View History

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?