summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJasper Van der Jeugt <m@jaspervdj.be>2012-06-30 12:27:08 +0200
committerJasper Van der Jeugt <m@jaspervdj.be>2012-06-30 12:27:08 +0200
commit33dc1a1bd218c85bc253da07a46a9d48e89375b4 (patch)
tree39f6fbbdc86e19999bc307eda7383bee88652b6b
parenteb274c09ace7bcf8d17a8da8548ae253a69d5568 (diff)
downloadstylish-haskell-33dc1a1bd218c85bc253da07a46a9d48e89375b4.tar.gz
Parse extra language extensions (not used yet)
-rw-r--r--.stylish-haskell.yaml11
-rw-r--r--src/Main.hs2
-rw-r--r--src/StylishHaskell/Config.hs6
3 files changed, 16 insertions, 3 deletions
diff --git a/.stylish-haskell.yaml b/.stylish-haskell.yaml
index bfa8595..0700d0b 100644
--- a/.stylish-haskell.yaml
+++ b/.stylish-haskell.yaml
@@ -1,6 +1,6 @@
# stylish-haskell configuration file
# ==================================
-#
+
# The stylish-haskell tool is mainly configured by specifying steps. These steps
# are a list, so they have an order, and one specific step may appear more than
# once (if needed). Each file is processed by these steps in the given order.
@@ -53,3 +53,12 @@ steps:
# Remove trailing whitespace
- trailing_whitespace: {}
+
+# Sometimes, language extensions are specified in a cabal file or from the
+# command line instead of using language pragmas in the file. stylish-haskell
+# needs to be aware of these, so it can parse the file correctly.
+#
+# No language extensions are enabled by default.
+# language_extensions:
+ # - TemplateHaskell
+ # - QuasiQuotes
diff --git a/src/Main.hs b/src/Main.hs
index f01df37..4b74c6f 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -61,6 +61,8 @@ stylishHaskell sa
conf <- loadConfig verbose' (config sa)
let steps = configSteps conf
forM_ steps $ \s -> verbose' $ "Enabled " ++ stepName s ++ " step"
+ verbose' $ "Extra language extensions: " ++
+ show (configLanguageExtensions conf)
mapM_ (file sa conf) files'
where
verbose' = makeVerbose (verbose sa)
diff --git a/src/StylishHaskell/Config.hs b/src/StylishHaskell/Config.hs
index f305cc3..7feef74 100644
--- a/src/StylishHaskell/Config.hs
+++ b/src/StylishHaskell/Config.hs
@@ -36,7 +36,8 @@ import StylishHaskell.Verbose
--------------------------------------------------------------------------------
data Config = Config
- { configSteps :: [Step]
+ { configSteps :: [Step]
+ , configLanguageExtensions :: [String]
}
@@ -47,7 +48,7 @@ instance FromJSON Config where
--------------------------------------------------------------------------------
emptyConfig :: Config
-emptyConfig = Config []
+emptyConfig = Config [] []
--------------------------------------------------------------------------------
@@ -101,6 +102,7 @@ loadConfig verbose mfp = do
parseConfig :: A.Value -> A.Parser Config
parseConfig (A.Object o) = Config
<$> (o A..: "steps" >>= fmap concat . mapM parseSteps)
+ <*> (o A..:? "language_extensions" A..!= [])
parseConfig _ = mzero