I'm writing a program in Haskell, and it involves a lot of parentheses. So to clear up that ugly mess, I use the $
operator a couple of times to make it easier to read. For example:
longFunc arg1 (anotherFunc (yetAnotherFunc arg2))
is replaced by
longFunc arg1 $ anotherFunc $ yetAnotherFunc arg2
But when I compile my program using GHCi I get a message saying:
MyFile.hs:18:18: error:
parse error on input ‘$’
Perhaps you intended to use TemplateHaskell
Failed, modules loaded: none.
Here's lines 16-18:
isDigit :: Char -> Bool
isDigit c =
c `elem` $ ['0'..'9'] ++ "."
I was confused because I have used the $
operator several times (with the same compiler) like this:
main = putStrLn $ show 42
So I typed that code into my file as a test, deleted the other $
occurrences, and loaded it up.
And it worked!
Can someone please tell me what's going on?