Functional Programming (H) - 5.09 - You are the type checker

1. What is the type of the head function?

2. What is the type of the putStrLn function?

3. Given the following type declarations:

f :: T1 -> T2 g :: T2 -> T3

And given that the following expression typechecks:

v :: T1 v = h f g

What is the type of h?

4. What is the type of the following function:

\f -> f f

5. Complete the following type definition to define a binary tree with the values stored only in the leaf nodes:

data Tree a = Node __ __ | Leaf __

6. What is the type of the following function (use a,b,c etc as type variables in order of occurence):

\x y -> y

7. Is the following expression correctly typed?

sq :: Int -> Float sq x = x*x

8. Is the following expression correctly typed?

join :: String -> [String] -> String join str strs = foldl (++) str strs