0

Can anybody tell me the function of $ in following Haskell line. $$ if for the last line but the function of $?

  concat $ replicate 3 "12345"
dfeuer
  • 47,935
  • 4
  • 60
  • 166
user3787092
  • 61
  • 1
  • 8

1 Answers1

5

$ is just a low precedence version of function application, i.e. a $ b is the same as a b.

It is commonly used to remove the need for parentheses, e.g.:

concat $ replicate 3 "12345"

is the same as:

concat (replicate 3 "12345")

Also, instead of having to write:

putStrLn ("hello " ++ name ++ "!")

you'll often see:

putStrLn $ "hello " ++ name ++ "!"
ErikR
  • 50,987
  • 8
  • 69
  • 122