我正在玩Haskell,但我无法弄清楚为什么反向函数应用程序运算符(&)不起作用。
例如在ghci我得到:
Prelude> "hello" & length
<interactive>:1:9: error:
Variable not in scope: (&) :: [Char] -> ([a0] -> Int) -> t
当我希望它返回5
时为什么不起作用?
答案 0 :(得分:6)
看起来不在范围内。 Asking Hoogle告诉我您需要从Data.Function
:
Prelude> import Data.Function
Prelude Data.Function> "hello" & length
5