SOE ex.5.2

map :: (a -> b) -> [a] -> [b]
foldl :: (b -> a -> b) -> b -> [a] -> b

(1)
map has type as (a -> b) -> [a] -> [b]
so let’s see what happen
map map [x] = [ map x ]
==> (map x) has type [a] -> [b] and x has type (a -> b)
==> [ map x ] has type [[a] -> [b]]
so,
(map map) :: [a -> b] -> [[a] -> [b]]

(2)
(foldl foldl) seems ill type.

(3)
map foldl [x] = [foldl x]
so, [foldl x] has type as [b -> [a] -> b] and x has type as (b -> a -> b)
so,
(map foldl) :: [b -> a -> b] -> [b -> [a] -> b]

Leave a Reply