我试图推导出的类型(.) (foldr(++)) (map (:))
我首先推导类型foldr (++)
foldr :: (a1 -> b1 -> b1) -> b1 -> [a1] -> b1
(++) :: [a2] -> [a2] -> [a2]
a1 ~ [a2]
b1 ~ [a2]
b1 ~ [a2]
所以
foldr (++) :: [a2] -> [[a2]] -> [a2] ~ [a] -> [[a]] -> [a]
然后我推导出类型map (:)
map :: (a1 -> b1) -> [a1] -> [b1]
(:) :: a2 -> [a2] -> [a2]
a1 ~ a2
b1 ~ [a2] -> [a2]
所以
map (:) :: [a2] -> [[a2] -> [a2]] ~ [a] -> [[a] -> [a]]
最后的类型(.) (foldr(++)) (map (:))
(.) :: (b1 -> c1) -> (a1 -> b1) -> a1 -> c1
map (:) :: [a2] -> [[a2] -> [a2]]
foldr (++) :: [a3] -> [[a3]] -> [a3]
b1 ~ [a2]
c1 ~ [[a2] -> [a2]]
a1 ~ [a3]
b1 ~ [[a3]] -> [a3]
所以我得到
(.) (foldr(++)) (map (:)) :: a1 -> c1 ~ [a3] -> [[a2] -> [a2]]
但是如果我问 GHCi:t (.) (foldr(++)) (map (:))
我得到(.) (foldr(++)) (map (:)) :: [a] -> [[[a] -> [a]]] -> [[a] -> [a]]
这与我的结果不同,有什么帮助可以得出相同的结果吗?
谢谢,
塞巴斯蒂安。