Can anybody tell me the function of $
in following Haskell line.
$$ if for the last line but the function of $
?
concat $ replicate 3 "12345"
Can anybody tell me the function of $
in following Haskell line.
$$ if for the last line but the function of $
?
concat $ replicate 3 "12345"
$
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 ++ "!"