Haskell反向函数应用程序运算符不工作

a54*_*4jh 1 haskell

我正在玩Haskell,但我无法弄清楚为什么反向函数应用程序运算符(&)不起作用.

例如在ghci我得到:

Prelude> "hello" & length

<interactive>:1:9: error:
    Variable not in scope: (&) :: [Char] -> ([a0] -> Int) -> t
Run Code Online (Sandbox Code Playgroud)

当我期望它返回5

为什么不起作用?

Kot*_*lar 6

看起来它不在范围内.询问Hoogle告诉我你需要从中导入它,例如Data.Function:

Prelude> import Data.Function
Prelude Data.Function> "hello" & length
5
Run Code Online (Sandbox Code Playgroud)