19 lines
729 B
TeX
19 lines
729 B
TeX
Let's start with a polymorphic function that you already know:
|
|
\begin{haskellcode}
|
|
head :: [a] -> a
|
|
\end{haskellcode}
|
|
\pause
|
|
So \hinline{head} takes a list of any type and returns an element which must have the \emph{exact same} type of that list.
|
|
\vspace{\baselineskip}
|
|
\\
|
|
\pause
|
|
We can also have:
|
|
\begin{haskellcode}
|
|
f :: a -> b
|
|
\end{haskellcode}
|
|
\pause
|
|
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! That's all we know about this function.
|
|
\vspace{\baselineskip}
|
|
\\
|
|
\pause
|
|
You don't have to use \hinline{a} or \hinline{b} here. These letters are just commonly used for generic types. |