Haskell:无点样式

Haskell: Point-free style

为什么第一个编译失败,而第二个编译成功?

我希望foofoo'是等价的,也就是说,foo'只是一个无点函数 共 foo 个:

foo :: [a] -> [a] -> [(a,a)]
foo = map id . zip

foo' :: [a] -> [a] -> [(a,a)]
foo' a b = map id $ zip a b

但是 foo 失败并出现以下错误:

Couldn't match type ‘[b0] -> [(a, b0)]’ with ‘[b]’
Expected type: [a] -> [b]
  Actual type: [a] -> [b0] -> [(a, b0)]
Relevant bindings include
  foo :: [a] -> [b] (bound at <interactive>:26:5)
Probable cause: ‘zip’ is applied to too few arguments
In the second argument of ‘(.)’, namely ‘zip’
In the expression: map id . zip

如有任何意见,我们将不胜感激。

如果您查看 (.) 的 definition/type 签名,您会发现它的参数是具有单个参数的函数。但是 zip 有两个,因此您必须至少提供一个参数才能使其等价于

foo a = map id . zip a