我试图理解为什么类型:
(flip .) is: (a -> a1 -> b -> c) -> a -> b -> a1 -> c
首先,类型:
flip: is (a -> b -> c) -> b -> a -> c
(.): is (b -> c) -> (a -> b) -> a -> c
我将在我的解释中将变量重命名为更清晰,因此类型:
flip: is (ax -> bx -> cx) -> bx -> ax -> cx
(.): is (by -> cy) -> (ay -> by) -> ay -> cy
然后我尝试这样替换:
ax = (by -> cy)
bx = (ay -> by)
cx = ay -> cy
因此得到的类型是:(ay - > by)(by - > cy) - > ay - > cy,与正确的结果不同。
任何帮助?
谢谢, 安。
答案 0 :(得分:7)
(flip .)
是(.) flip
,所以:
(.) :: (bx -> cx) -> (ax -> bx) -> ax -> cx
flip :: (ay -> by -> cy) -> by -> ay -> cy
(.) flip
中,
bx
是ay -> by -> cy
cx
是by -> ay -> cy
(ax -> (ay -> by -> cy)) -> ax -> (by -> ay -> cy)
,(ax -> ay -> by -> cy) -> ax -> by -> ay -> cy
,(flip .) :: (a -> a1 -> b -> c) -> a -> b -> a1 -> c
匹配。