summaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2016-07-07 13:36:18 +0200
committerGitHub <noreply@github.com>2016-07-07 13:36:18 +0200
commitabc92ea4778ac25b7944b9f4c7f82eb95f0238c2 (patch)
treeb0917555b112062f293283addf938ddf01e975e9 /lib
parentf1dd5c4be6065bedc8cd764767b7c05420a9d40d (diff)
parent486dcc2da09017b09eeb82001bf0d2cdba5043d0 (diff)
downloadstylish-haskell-abc92ea4778ac25b7944b9f4c7f82eb95f0238c2.tar.gz
Merge pull request #116 from nightuser/newlineformat
Add newline format option
Diffstat (limited to 'lib')
-rw-r--r--lib/Language/Haskell/Stylish/Config.hs10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/Language/Haskell/Stylish/Config.hs b/lib/Language/Haskell/Stylish/Config.hs
index 7994216..b25f343 100644
--- a/lib/Language/Haskell/Stylish/Config.hs
+++ b/lib/Language/Haskell/Stylish/Config.hs
@@ -24,6 +24,8 @@ import System.Directory
import System.FilePath (joinPath,
splitPath,
(</>))
+import qualified System.IO as IO (Newline (..),
+ nativeNewline)
--------------------------------------------------------------------------------
@@ -48,6 +50,7 @@ data Config = Config
{ configSteps :: [Step]
, configColumns :: Int
, configLanguageExtensions :: [String]
+ , configNewline :: IO.Newline
}
@@ -116,11 +119,18 @@ parseConfig (A.Object o) = do
<$> pure []
<*> (o A..:? "columns" A..!= 80)
<*> (o A..:? "language_extensions" A..!= [])
+ <*> (o A..:? "newline" >>= parseEnum newlines IO.nativeNewline)
-- Then fill in the steps based on the partial config we already have
stepValues <- o A..: "steps" :: A.Parser [A.Value]
steps <- mapM (parseSteps config) stepValues
return config {configSteps = concat steps}
+ where
+ newlines =
+ [ ("native", IO.nativeNewline)
+ , ("lf", IO.LF)
+ , ("crlf", IO.CRLF)
+ ]
parseConfig _ = mzero