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
  • 48,079
  • 5
  • 63
  • 167
user3787092
  • 71
  • 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
  • 51,541
  • 9
  • 73
  • 124