
Language.Haskell.Parser currently can't parse modules with unicode symbols in operators, which are allowed by the haskell98 standard. The attached patch is a small change in the lexer code to fix this. Since parseModule expects a String of Unicode codepoints as usual, examples/hsparser.hs will still raise errors on modules that use unicode, because it doesn't decode the source. The correct behaviour, assuming an utf-8 source, can be tested like this:
import System.IO.UTF8 as U -- from utf8-string import Language.Haskell.Parser import Language.Haskell.Pretty main = do file <- U.readFile "module.hs" case parseModule of ParseOk m -> U.putStrLn (prettyPrint m) e@(ParseError _ _) = print e

Looks good to me. Ian, do you want to apply this? sanzhiyan:
Language.Haskell.Parser currently can't parse modules with unicode symbols in operators, which are allowed by the haskell98 standard. The attached patch is a small change in the lexer code to fix this. Since parseModule expects a String of Unicode codepoints as usual, examples/hsparser.hs will still raise errors on modules that use unicode, because it doesn't decode the source. The correct behaviour, assuming an utf-8 source, can be tested like this:
import System.IO.UTF8 as U -- from utf8-string import Language.Haskell.Parser import Language.Haskell.Pretty main = do file <- U.readFile "module.hs" case parseModule of ParseOk m -> U.putStrLn (prettyPrint m) e@(ParseError _ _) = print e
_______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries

Language.Haskell.Parser currently can't parse modules with unicode symbols in operators, which are allowed by the haskell98 standard. The attached patch is a small change in the lexer code to fix this.
Thanks Andrea, I'm stealing this for haskell-src-exts as well. :-) Cheers, /Niklas
participants (3)
-
Andrea Vezzosi
-
Don Stewart
-
Niklas Broberg