4

I'm playing around with Haskell, but I can't figure out why the reverse function application operator (&) is not working.

For example in ghci I get:

Prelude> "hello" & length

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

When I expect it to return 5

Why is it not working?

1
  • 2
    It is in the Data.Function module, and not reimported in the Prelude, so you need to import it yourself. Commented Mar 20, 2018 at 20:56

1 Answer 1

8

Looks like it's not in scope. Asking Hoogle tells me that you need to import it from, for example, Data.Function:

Prelude> import Data.Function
Prelude Data.Function> "hello" & length
5
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.