EDIT: I had 4 mistakes in total.
In line 5 I had "''", which does not have any meaning.
In line 9 I had "map (asciiRotC)". This should be "map (asciiRotC n)"
In line 13 I had "x:xs. This should be "(x:xs)".
In the last line I had "asciiRotWith 0 (+1)". This should be "... (+1) 0"
Here is my full code (the file is called asciiRot.hs):
import System.Environment
import System.IO
asciiRotC :: Int -> Char -> Char
asciiRotC _ '' = ''
asciiRotC 0 msg = msg
asciiRotC n msg = toEnum (33 + (n + (fromEnum msg) - 33) `mod` 93) :: Char
asciiRot :: Int -> String -> String
asciiRot n msg = map (asciiRotC) msg
asciiRotWith :: (Int->Int) -> Int -> String -> String
asciiRotWith _ _ "" = ""
asciiRotWith f acc x:xs = (asciiRotC acc x) : (asciiRotWith f (f acc) xs)
main = do
args <- getArgs
putStrLn $ asciiRotWith 0 (+1) (head args)
The error I get is: asciiRot.hs:8:16: parse error on input `='
I've searched for similar error, and found that they are mostly related to indentation or trying to do things in ghci, but this is not the case, am trying to compile, and I use spaces for indentation.
I tried to add an extra space in line 8, to match all the eual signs, but the error does not change.
I am using Debian 7, ghc "The Glorious Glasgow Haskell Compilation System, version 7.4.1". I am writting my code in vim, and compiling with ghc asciiRot.hs
An earlier version would work. Here it is:
asciiRot :: Int -> String -> String
asciiRot _ "" = ""
asciiRot 0 msg = msg
asciiRot n msg = map (\x -> toEnum (33 + (n + (fromEnum x) - 33) `mod` 93) :: Char) msg
This one I would run in ghci, with :l asciiRot.hs