diff options
author | Svyatoslav Gryaznov <nightuser@ya.ru> | 2016-07-05 16:45:29 +0300 |
---|---|---|
committer | Svyatoslav Gryaznov <nightuser@ya.ru> | 2016-07-05 16:45:29 +0300 |
commit | 637872f6ea4a37d2a4162c95d7cb0304efc41d19 (patch) | |
tree | 8e4fb29fa1537392bc4a41405c253d538b65bb95 /lib | |
parent | fd5e7df4896845a113d03cefac9a710d2252aa19 (diff) | |
download | stylish-haskell-637872f6ea4a37d2a4162c95d7cb0304efc41d19.tar.gz |
Add newline format option
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Language/Haskell/Stylish/Config.hs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/Language/Haskell/Stylish/Config.hs b/lib/Language/Haskell/Stylish/Config.hs index fee7594..d921b09 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) -------------------------------------------------------------------------------- @@ -47,6 +49,7 @@ data Config = Config { configSteps :: [Step] , configColumns :: Int , configLanguageExtensions :: [String] + , configNewline :: IO.Newline } @@ -115,11 +118,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 |