What does lexical error at '\a' mean and how do I fix it?

140 Views Asked by At

I am new to haskell and was trying to run the following bit of code, but somehow got this error: lexical error at character '\a'. This error wasn't happening until I added the let loop = do .... (The line 9 comment isn't in the original code) Code:

start :: IO ()
start = do
--  <- line 9
    let indices = listOptions [True, False, False, False, True, True, True]
    let loop = do
            putStrLn "---menu---"
            printOptions ["New game", "Load game", "Delete game", "Layouts", "Overview", "Refresh", "Leave"] indices
            putStr "Enter: "
            hFlush stdout
            choice <- getLine
            let input = case readMaybe choice :: Maybe Int of
                    Just a -> a
                    Nothing -> -1
            direct 0 input indices
    loop

Error:

main.hs:9:5: error: lexical error at character '\a'
  |
9 |     
  |     ^

Originally, the code on line 10 was on line 9, so I re-wrote the line on line 10 and deleted it thinking that would solve the problem. I also tried looking for what '\a' it see if that could help, but I was unable to find information on it. I even removed the empty line, so the let indices = ... is one line 9, but that didn't work either.

Hexdump:

6d 6f 64 75 6c 65 20 4d 65 6e 75 20 77 68 65 72
65 0d 0a 0d 0a 69 6d 70 6f 72 74 20 53 79 73 74
65 6d 2e 49 4f 0d 0a 69 6d 70 6f 72 74 20 53 79
73 74 65 6d 2e 45 78 69 74 28 65 78 69 74 53 75
63 63 65 73 73 29 0d 0a 69 6d 70 6f 72 74 20 54
65 78 74 2e 52 65 61 64 0d 0a 0d 0a 73 74 61 72
74 20 3a 3a 20 49 4f 20 28 29 0d 0a 73 74 61 72
74 20 3d 20 64 6f 0d 0a 2d 2d 20 20 3c 2d 20 6c
69 6e 65 20 39 0d 0a 20 20 20 20 6c 65 74 20 69
6e 64 69 63 65 73 20 3d 20 6c 69 73 74 4f 70 74
69 6f 6e 73 20 5b 54 72 75 65 2c 20 46 61 6c 73
65 2c 20 46 61 6c 73 65 2c 20 46 61 6c 73 65 2c
20 54 72 75 65 2c 20 54 72 75 65 2c 20 54 72 75
65 5d 0d 0a 20 20 20 20 6c 65 74 20 6c 6f 6f 70
20 3d 20 64 6f 0d 0a 20 20 20 20 20 20 20 20 20
20 20 20 70 75 74 53 74 72 4c 6e 20 22 2d 2d 2d
6d 65 6e 75 2d 2d 2d 22 0d 0a 20 20 20 20 20 20
20 20 20 20 20 20 70 72 69 6e 74 4f 70 74 69 6f
6e 73 20 5b 22 4e 65 77 20 67 61 6d 65 22 2c 20
22 4c 6f 61 64 20 67 61 6d 65 22 2c 20 22 44 65
6c 65 74 65 20 67 61 6d 65 22 2c 20 22 4c 61 79
6f 75 74 73 22 2c 20 22 4f 76 65 72 76 69 65 77
22 2c 20 22 52 65 66 72 65 73 68 22 2c 20 22 4c
65 61 76 65 22 5d 20 69 6e 64 69 63 65 73 0d 0a
20 20 20 20 20 20 20 20 20 20 20 20 70 75 74 53
74 72 20 22 45 6e 74 65 72 3a 20 22 0d 0a 20 20
20 20 20 20 20 20 20 20 20 20 68 46 6c 75 73 68
20 73 74 64 6f 75 74 0d 0a 20 20 20 20 20 20 20
20 20 20 20 20 63 68 6f 69 63 65 20 3c 2d 20 67
65 74 4c 69 6e 65 0d 0a 20 20 20 20 20 20 20 20
20 20 20 20 6c 65 74 20 69 6e 70 75 74 20 3d 20
63 61 73 65 20 72 65 61 64 4d 61 79 62 65 20 63
68 6f 69 63 65 20 3a 3a 20 4d 61 79 62 65 20 49
6e 74 20 6f 66 0d 0a 20 20 20 20 20 20 20 20 20
20 20 20 20 20 20 20 20 20 20 20 4a 75 73 74 20
61 20 2d 3e 20 61 0d 0a 20 20 20 20 20 20 20 20
20 20 20 20 20 20 20 20 20 20 20 20 4e 6f 74 68
69 6e 67 20 2d 3e 20 2d 31 0d 0a 20 20 20 20 20
20 20 20 20 20 20 20 64 69 72 65 63 74 20 30 20
69 6e 70 75 74 20 69 6e 64 69 63 65 73 0d 0a 20
20 20 20 6c 6f 6f 70 0d 0a 0d 0a 6c 69 73 74 4f
70 74 69 6f 6e 73 20 3a 3a 20 5b 42 6f 6f 6c 5d
20 2d 3e 20 5b 49 6e 74 5d 0d 0a 6c 69 73 74 4f
70 74 69 6f 6e 73 20 61 70 70 6c 69 63 61 62 6c
65 20 3d 20 6c 69 73 74 4f 70 74 69 6f 6e 73 48
65 6c 70 65 72 20 61 70 70 6c 69 63 61 62 6c 65
20 31 0d 0a 0d 0a 6c 69 73 74 4f 70 74 69 6f 6e
73 48 65 6c 70 65 72 20 3a 3a 20 5b 42 6f 6f 6c
5d 20 2d 3e 20 49 6e 74 20 2d 3e 20 5b 49 6e 74
5d 0d 0a 6c 69 73 74 4f 70 74 69 6f 6e 73 48 65
6c 70 65 72 20 28 61 70 70 20 3a 20 61 70 70 73
29 20 69 6e 64 65 78 0d 0a 20 20 20 20 7c 20 61
70 70 20 3d 20 69 6e 64 65 78 20 3a 20 6c 69 73
74 4f 70 74 69 6f 6e 73 48 65 6c 70 65 72 20 61
70 70 73 20 28 69 6e 64 65 78 20 2b 20 31 29 0d
0a 20 20 20 20 7c 20 6f 74 68 65 72 77 69 73 65
20 3d 20 2d 31 20 3a 20 6c 69 73 74 4f 70 74 69
6f 6e 73 48 65 6c 70 65 72 20 61 70 70 73 20 69
6e 64 65 78 0d 0a 6c 69 73 74 4f 70 74 69 6f 6e
73 48 65 6c 70 65 72 20 5f 20 5f 20 3d 20 5b 5d
0d 0a 0d 0a 70 72 69 6e 74 4f 70 74 69 6f 6e 73
20 3a 3a 20 5b 53 74 72 69 6e 67 5d 20 2d 3e 20
5b 49 6e 74 5d 20 2d 3e 20 49 4f 20 28 29 0d 0a
70 72 69 6e 74 4f 70 74 69 6f 6e 73 20 28 76 20
3a 20 76 73 29 20 28 69 6e 64 65 78 20 3a 20 69
6e 64 69 63 65 73 29 0d 0a 20 20 20 20 7c 20 69
6e 64 65 78 20 3d 3d 20 2d 31 20 3d 20 64 6f 0d
0a 20 20 20 20 20 20 20 20 70 75 74 53 74 72 4c
6e 20 24 20 22 58 2e 22 20 2b 2b 20 76 0d 0a 20
20 20 20 20 20 20 20 70 72 69 6e 74 4f 70 74 69
6f 6e 73 20 76 73 20 69 6e 64 69 63 65 73 0d 0a
20 20 20 20 7c 20 6f 74 68 65 72 77 69 73 65 20
3d 20 64 6f 0d 0a 20 20 20 20 20 20 20 20 70 75
74 53 74 72 4c 6e 20 24 20 28 73 68 6f 77 20 69
6e 64 65 78 29 20 2b 2b 20 22 2e 22 20 2b 2b 20
76 0d 0a 20 20 20 20 20 20 20 20 70 72 69 6e 74
4f 70 74 69 6f 6e 73 20 76 73 20 69 6e 64 69 63
65 73 0d 0a 70 72 69 6e 74 4f 70 74 69 6f 6e 73
20 5f 20 5f 20 3d 20 70 75 74 53 74 72 20 22 22
0d 0a 0d 0a 64 69 72 65 63 74 20 3a 3a 20 49 6e
74 20 2d 3e 20 49 6e 74 20 2d 3e 20 5b 49 6e 74
5d 20 2d 3e 20 49 4f 20 28 29 0d 0a 64 69 72 65
63 74 20 69 20 69 6e 70 75 74 20 28 6f 70 74 69
6f 6e 20 3a 20 6f 70 74 69 6f 6e 73 29 0d 0a 20
20 20 20 7c 20 69 6e 70 75 74 20 3e 20 30 20 26
26 20 69 6e 70 75 74 20 3d 3d 20 6f 70 74 69 6f
6e 20 3d 20 63 61 73 65 20 69 20 6f 66 0d 0a 20
20 20 20 20 20 20 20 30 20 2d 3e 20 70 75 74 53
74 72 4c 6e 20 22 31 22 0d 0a 20 20 20 20 20 20
20 20 31 20 2d 3e 20 70 75 74 53 74 72 4c 6e 20
22 32 22 0d 0a 20 20 20 20 20 20 20 20 32 20 2d
3e 20 70 75 74 53 74 72 4c 6e 20 22 33 22 0d 0a
20 20 20 20 20 20 20 20 33 20 2d 3e 20 70 75 74
53 74 72 4c 6e 20 22 34 22 0d 0a 20 20 20 20 20
20 20 20 34 20 2d 3e 20 70 75 74 53 74 72 4c 6e
20 22 35 22 0d 0a 20 20 20 20 20 20 20 20 35 20
2d 3e 20 70 75 74 53 74 72 4c 6e 20 22 36 22 0d
0a 20 20 20 20 20 20 20 20 36 20 2d 3e 20 65 78
69 74 53 75 63 63 65 73 73 0d 0a 20 20 20 20 20
20 20 20 5f 20 2d 3e 20 70 75 74 53 74 72 4c 6e
20 22 49 6e 76 61 69 6c 64 20 69 6e 70 75 74 22
0d 0a 20 20 20 20 7c 20 69 6e 70 75 74 20 3c 20
30 20 3d 20 70 75 74 53 74 72 4c 6e 20 22 49 6e
76 61 69 64 20 69 6e 70 75 74 22 0d 0a 20 20 20
20 7c 20 6f 74 68 65 72 77 69 73 65 20 3d 20 64
69 72 65 63 74 20 28 69 20 2b 20 31 29 20 69 6e
70 75 74 20 6f 70 74 69 6f 6e 73 0d 0a 64 69 72
65 63 74 20 5f 20 5f 20 5b 5d 20 3d 20 70 75 74
53 74 72 4c 6e 20 22 49 6e 76 61 6c 69 64 20 69
6e 70 75 74 22

Edit: I tried restarting my computer that that made the error go from line nine to line eight Edit 2: I somehow managed to fix it. I went to the main function and commented out the start function call and printed "Hello", which gave another error with the same problem, then deleted the putStrLn "Hello" and uncommented the start function call. And it (somehow) started working again?!

Edit 3: I was using Notepad++, and bound the keyboard shortcut ctrl+shift+h to run the script. I must've missed clicked and typed ctrl+shift+g, which types, presumably, 0x07 character.

0

There are 0 best solutions below