summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorJasper Van der Jeugt <m@jaspervdj.be>2013-08-03 10:36:23 +0200
committerJasper Van der Jeugt <m@jaspervdj.be>2013-08-03 10:36:23 +0200
commit83d0fa032119907de17ccd8854a97fe426c1f68f (patch)
tree0b313faf5e7bc88191bb4b9f77ae4d17975b088b /src
parent105a1845152876bb7c49acda190e995c64659d01 (diff)
downloadstylish-haskell-83d0fa032119907de17ccd8854a97fe426c1f68f.tar.gz
Strip BOM *before* reading language extensions
Diffstat (limited to 'src')
-rw-r--r--src/Language/Haskell/Stylish/Parse.hs9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/Language/Haskell/Stylish/Parse.hs b/src/Language/Haskell/Stylish/Parse.hs
index 36422d1..5162527 100644
--- a/src/Language/Haskell/Stylish/Parse.hs
+++ b/src/Language/Haskell/Stylish/Parse.hs
@@ -40,8 +40,9 @@ dropBom str = str
parseModule :: Extensions -> Maybe FilePath -> String -> Either String Module
parseModule extraExts mfp string = do
-- Determine the extensions: those specified in the file and the extra ones
- let extraExts' = map H.classifyExtension extraExts
- fileExts = fromMaybe [] $ H.readExtensions string
+ let noBom = dropBom string
+ extraExts' = map H.classifyExtension extraExts
+ fileExts = fromMaybe [] $ H.readExtensions noBom
exts = fileExts ++ extraExts'
-- Parsing options...
@@ -50,9 +51,9 @@ parseModule extraExts mfp string = do
{H.extensions = exts, H.fixities = Nothing}
-- Preprocessing
- string' = dropBom $ (if H.CPP `elem` exts then unCpp else id) $ string
+ noCpp = if H.CPP `elem` exts then unCpp noBom else noBom
- case H.parseModuleWithComments mode string' of
+ case H.parseModuleWithComments mode noCpp of
H.ParseOk md -> return md
err -> throwError $
"Language.Haskell.Stylish.Parse.parseModule: could not parse " ++