Because the second one is:

  take (succ 10 (cycle “hello world”))

On Thu, Aug 20, 2020 at 12:03 Josh Friedlander <joshuatfriedlander@gmail.com> wrote:
I understand that in general $ is a) right-associative and b) lowest-priority. But if so shouldn't these two be roughly the same?

λ take (succ 10) $ cycle "hello world"
"hello world"

But not this?
λ take $ succ 10 $ cycle "hello world"

<interactive>:20:8: error:
    • No instance for (Enum ([Char] -> Int))
        arising from a use of ‘succ’
        (maybe you haven't applied a function to enough arguments?)
    • In the expression: succ 10
      In the second argument of ‘($)’, namely
        ‘succ 10 $ cycle "hello world"’
      In the expression: take $ succ 10 $ cycle "hello world"

<interactive>:20:13: error:
    • No instance for (Num ([Char] -> Int))
        arising from the literal ‘10’
        (maybe you haven't applied a function to enough arguments?)
    • In the first argument of ‘succ’, namely ‘10’
      In the expression: succ 10
      In the second argument of ‘($)’, namely
        ‘succ 10 $ cycle "hello world"’


_______________________________________________

Beginners mailing list

Beginners@haskell.org

http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners