2

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
  • Your code is not properly indented. cs and putStr should start on exactly the same column. Commented Jan 5, 2021 at 9:01

1 Answer 1

5

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.