summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/Language/Haskell/Stylish/Parse.hs39
-rw-r--r--stylish-haskell.cabal8
2 files changed, 16 insertions, 31 deletions
diff --git a/src/Language/Haskell/Stylish/Parse.hs b/src/Language/Haskell/Stylish/Parse.hs
index d9e0c9b..ac5aafb 100644
--- a/src/Language/Haskell/Stylish/Parse.hs
+++ b/src/Language/Haskell/Stylish/Parse.hs
@@ -36,43 +36,28 @@ dropBom str = str
--------------------------------------------------------------------------------
--- | If
---
--- > {-# LANGUAGE Haskell2010 #-}
---
--- is specified, we need to add a number of extra extensions
-addHaskell2010Extensions :: [H.Extension] -> [H.Extension]
-addHaskell2010Extensions exts
- -- For some reason Haskell2010 is not supported yet in haskell-src-exts
- | H.UnknownExtension "Haskell2010" `elem` exts = exts ++ extra
- | otherwise = exts
- where
- extra =
- [ H.PatternGuards
- , H.RelaxedPolyRec
- , H.EmptyDataDecls
- , H.ForeignFunctionInterface
- , H.UnknownExtension "NoNPlusKPatterns" -- Not supported yet in HSE
- ]
-
-
---------------------------------------------------------------------------------
-- | Abstraction over HSE's parsing
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
- extraExts' = map H.classifyExtension extraExts
- fileExts = fromMaybe [] $ H.readExtensions noBom
- exts = addHaskell2010Extensions $ fileExts ++ extraExts'
+ let noBom = dropBom string
+ extraExts' = map H.classifyExtension extraExts
+ (lang, fileExts) = fromMaybe (Nothing, []) $ H.readExtensions noBom
+ exts = fileExts ++ extraExts'
-- Parsing options...
fp = fromMaybe "<unknown>" mfp
mode = H.defaultParseMode
- {H.extensions = exts, H.fixities = Nothing}
+ { H.extensions = exts
+ , H.fixities = Nothing
+ , H.baseLanguage = case lang of
+ Nothing -> H.baseLanguage H.defaultParseMode
+ Just l -> l
+ }
-- Preprocessing
- noCpp = if H.CPP `elem` exts then unCpp noBom else noBom
+ noCpp =
+ if H.EnableExtension H.CPP `elem` exts then unCpp noBom else noBom
case H.parseModuleWithComments mode noCpp of
H.ParseOk md -> return md
diff --git a/stylish-haskell.cabal b/stylish-haskell.cabal
index 7250822..6e01e39 100644
--- a/stylish-haskell.cabal
+++ b/stylish-haskell.cabal
@@ -1,5 +1,5 @@
Name: stylish-haskell
-Version: 0.5.7.0
+Version: 0.5.8.0
Synopsis: Haskell code prettifier
Homepage: https://github.com/jaspervdj/stylish-haskell
License: BSD3
@@ -49,7 +49,7 @@ Library
containers >= 0.3 && < 0.6,
directory >= 1.1 && < 1.3,
filepath >= 1.1 && < 1.4,
- haskell-src-exts >= 1.13 && < 1.14,
+ haskell-src-exts >= 1.14 && < 1.15,
mtl >= 2.0 && < 2.2,
syb >= 0.3 && < 0.5,
yaml >= 0.7 && < 0.9
@@ -70,7 +70,7 @@ Executable stylish-haskell
containers >= 0.3 && < 0.6,
directory >= 1.1 && < 1.3,
filepath >= 1.1 && < 1.4,
- haskell-src-exts >= 1.13 && < 1.14,
+ haskell-src-exts >= 1.14 && < 1.15,
mtl >= 2.0 && < 2.2,
syb >= 0.3 && < 0.5,
yaml >= 0.7 && < 0.9
@@ -103,7 +103,7 @@ Test-suite stylish-haskell-tests
containers >= 0.3 && < 0.6,
directory >= 1.1 && < 1.3,
filepath >= 1.1 && < 1.4,
- haskell-src-exts >= 1.13 && < 1.14,
+ haskell-src-exts >= 1.14 && < 1.15,
mtl >= 2.0 && < 2.2,
syb >= 0.3 && < 0.5,
yaml >= 0.7 && < 0.9