所以我在玩 y-combinator 和匿名函数,我遇到了这个奇怪的错误:
Couldn't match expected type `t0 -> t1 -> t2'
with actual type `forall b. b -> [b] -> [b]'
The lambda expression `\ (n :: Int) newVal xs -> ...'
has three arguments,
but its type `Int -> forall b. b -> [b] -> [b]' has only one
(产生错误的源代码,以及我最终开始工作的版本)
如果我稍微修改类型以避免 Rank N polymorphism (use forall b. Int -> b -> [b] -> [b]
),错误是相似的:
Couldn't match expected type `t0 -> t1 -> t2 -> t3'
with actual type `forall b. Int -> b -> [b] -> [b]'
The lambda expression `\ (n :: Int) newVal xs -> ...'
has three arguments,
but its type `forall b. Int -> b -> [b] -> [b]' has none
有人可以向我解释为什么 forall b. b -> [b] -> [b]
没有论据吗?