0

我试图理解为什么类型:

(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,与正确的结果不同。

有什么帮助吗?

谢谢,塞巴斯蒂安。

4

1 回答 1

7

(flip .)(.) flip,所以:

  • (.) :: (bx -> cx) -> (ax -> bx) -> ax -> cx
  • flip :: (ay -> by -> cy) -> by -> ay -> cy
  • (.) flip,
    • bxay -> by -> cy
    • cxby -> ay -> cy
    • 所以 it's all (ax -> (ay -> by -> cy)) -> ax -> (by -> ay -> cy),
      which is just (ax -> ay -> by -> cy) -> ax -> by -> ay -> cy,
      匹配(flip .) :: (a -> a1 -> b -> c) -> a -> b -> a1 -> c.
于 2014-04-20T21:09:52.730 回答