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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With