File tree 1 file changed +10
-2
lines changed 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,14 @@ unCpp = unlines . map unCpp' . lines
24
24
unCpp' xs = xs
25
25
26
26
27
+ --------------------------------------------------------------------------------
28
+ -- | If the given string is prefixed with an UTF-8 Byte Order Mark, drop it
29
+ -- because haskell-src-exts can't handle it.
30
+ dropBom :: String -> String
31
+ dropBom (' \xfeff ' : str) = str
32
+ dropBom str = str
33
+
34
+
27
35
--------------------------------------------------------------------------------
28
36
-- | Read an extension name from a string
29
37
parseExtension :: String -> Either String H. Extension
@@ -46,8 +54,8 @@ parseModule extraExts mfp string = do
46
54
mode = H. defaultParseMode
47
55
{H. extensions = exts, H. fixities = Nothing }
48
56
49
- -- Special handling for CPP, haskell-src-exts can't deal with it
50
- string' = if H. CPP `elem` exts then unCpp string else string
57
+ -- Preprocessing
58
+ string' = dropBom $ ( if H. CPP `elem` exts then unCpp else id ) $ string
51
59
52
60
case H. parseModuleWithComments mode string' of
53
61
H. ParseOk md -> return md
You can’t perform that action at this time.
0 commit comments