How do you fix Parse error on input ‘->’ on Haskell?

Viewed 103

The code below is for a calculator I have written. I am trying to handle parse error and token error but I keep receiving the same error on ∖s -> tokens s How do I fix this? Why do I keep getting this error?

 {- main -}
 main = do cs <- getContents
           putStr $ unlines $ map show $
            map (∖s -> tokens s >= parse >= eval) $ lines cs
1 Answers

The problem here is a subtle one. The correct syntax is \s -> tokens s >= parse >= eval, using a backslash: \ U+005C REVERSE SOLIDUS. However, instead your code is ∖s -> tokens s >= parse >= eval. This is subtly different: instead of using a backslash as expected, it instead uses ∖ U+2216 SET MINUS. Simply use the correct character, by replacing ∖ with \, and it should parse correctly.

Related