问题描述
我试图理解为什么类型:
(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,它是不同的正确结果。
任何帮助?
谢谢,
Sebastián。
(flip。) is ,所以:
- (。)::(bx - > cx) - > (ax - > bx) - > ax - > cx
- flip ::(ay - > by - > cy) - > by - > ay - >在(。)翻转中,
li> bx 是 ay - > by - > cy - cx 是 by - > ay - > cy
- 所以全部是(ax - >(ay - > by - > cy)) - > ax - > (by - > ay - > cy),
这就是(ax - > ay - > by - > cy) - > ax - > by - > ay - >与(flip。)::(a - > a1 - > b - > c)匹配的cy ,
>> a - > b - > a1 - > c 。
I'm trying to understand why the type of:
(flip .) is: (a -> a1 -> b -> c) -> a -> b -> a1 -> c
First of all, the type of:
flip: is (a -> b -> c) -> b -> a -> c(.): is (b -> c) -> (a -> b) -> a -> c
I will rename the variables to be more clear in my explanation, so the types:
flip: is (ax -> bx -> cx) -> bx -> ax -> cx(.): is (by -> cy) -> (ay -> by) -> ay -> cy
Then I try substituing like this:
ax = (by -> cy)bx = (ay -> by)cx = ay -> cy
So the resulting type is: (ay -> by) (by -> cy) -> ay -> cy, which is different with the correct result.
Any help?
Thanks,Sebastián.
(flip .) is (.) flip, so:
- (.) :: (bx -> cx) -> (ax -> bx) -> ax -> cx
- flip :: (ay -> by -> cy) -> by -> ay -> cy
- In (.) flip,
- bx is ay -> by -> cy
- cx is by -> ay -> cy
- so it’s all (ax -> (ay -> by -> cy)) -> ax -> (by -> ay -> cy),
which is just (ax -> ay -> by -> cy) -> ax -> by -> ay -> cy,
which matches up with (flip .) :: (a -> a1 -> b -> c) -> a -> b -> a1 -> c.
这篇关于(翻转)的类型是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!