diff options
author | Mathew Mills <mathewmills@mac.com> | 2016-04-27 20:54:15 -0700 |
---|---|---|
committer | Mathew Mills <mathewmills@mac.com> | 2016-04-27 20:54:15 -0700 |
commit | 586f457e6398c1b26767f00c52f037dcdf709eea (patch) | |
tree | b366c35d864d5203f143232a0292f4670d3c4d36 /lib | |
parent | 4a6ccd2fdfbb3890eecd802ee7368c4314b7f87a (diff) | |
download | stylish-haskell-586f457e6398c1b26767f00c52f037dcdf709eea.tar.gz |
Remove shebang from input before attempting to extract extension pragmas.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Language/Haskell/Stylish/Parse.hs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/Language/Haskell/Stylish/Parse.hs b/lib/Language/Haskell/Stylish/Parse.hs index f8e24a6..3118380 100644 --- a/lib/Language/Haskell/Stylish/Parse.hs +++ b/lib/Language/Haskell/Stylish/Parse.hs @@ -9,7 +9,6 @@ import Data.Maybe (fromMaybe, listToMaybe) import qualified Language.Haskell.Exts.Annotated as H import Data.List (isPrefixOf) - -------------------------------------------------------------------------------- import Language.Haskell.Stylish.Config import Language.Haskell.Stylish.Step @@ -48,9 +47,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 noBom = dropBom string + let noPrefixes = unShebang . dropBom $ string extraExts' = map H.classifyExtension extraExts - (lang, fileExts) = fromMaybe (Nothing, []) $ H.readExtensions noBom + (lang, fileExts) = fromMaybe (Nothing, []) $ H.readExtensions noPrefixes exts = fileExts ++ extraExts' -- Parsing options... @@ -64,8 +63,9 @@ parseModule extraExts mfp string = do } -- Preprocessing - processed = unShebang $ - if H.EnableExtension H.CPP `elem` exts then unCpp noBom else noBom + processed = if H.EnableExtension H.CPP `elem` exts + then unCpp noPrefixes + else noPrefixes case H.parseModuleWithComments mode processed of H.ParseOk md -> return md |