Reputation: 7374
Why is not ghci throwing a type error when I do the following?
let d = tail . head
Should this not say that tail wants [a] while head gives it only a?
Upvotes: 4
Views: 90
Reputation: 320
If the types were more specialized, like
head :: [Int] -> Int
tail :: [Int] -> [Int]
then tail.head would be ill typed indeed. But as it stands, the types are
head :: [a] -> a
tail :: [b] -> [b]
I have used the type variables "a" and "b" so that you don't think they have to be the same. In that case, having a = [b], the types become
head :: [[b]] -> [b]
tail :: [b] -> [b]
and they are composable.
Upvotes: 8