2015-04-21 12:28:01 +00:00
Let's start with a polymorphic function that you already know:
2015-04-19 22:32:50 +00:00
\begin { haskellcode}
2015-04-21 12:28:01 +00:00
head :: [a] -> a
2015-04-19 22:32:50 +00:00
\end { haskellcode}
\pause
2015-04-21 12:28:01 +00:00
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:
2015-04-19 22:32:50 +00:00
\begin { haskellcode}
f :: a -> b
\end { haskellcode}
2015-04-21 12:28:01 +00:00
\pause
2015-04-21 16:05:07 +00:00
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.
2015-04-19 22:32:50 +00:00
\vspace { \baselineskip }
\\
\pause
2015-04-21 12:28:01 +00:00
You don't have to use \hinline { a} or \hinline { b} here. These letters are just commonly used for generic types.