This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
main = do | |
let n = 3 | |
print n |
$ runghc a.hs
a.hs:3:11: error: Variable not in scope: n
たぶんこのようなエラーになるはずです。
最初はなぜエラーになるのか理解できませんでした。
Vim上ではまったく見た目は同じです。
カーソルをのせてみると違いがわかります。
show してみると
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
main = do | |
putStrLn $ show "n" | |
putStrLn $ show "n" |
$ runghc b.hs
"n"
"\65358"
65358は、16進の"ff4e"
つまりUnicodeの小文字 n です。
対して2行目の n はアスキー。
これはコードを日本語入力がONのまま修正したことでおこりました。
見た目は同じでも異なる文字なのでエラーとなりました。