diff options
author | Jasper Van der Jeugt <m@jaspervdj.be> | 2013-12-18 11:37:54 +0100 |
---|---|---|
committer | Jasper Van der Jeugt <m@jaspervdj.be> | 2013-12-18 11:37:54 +0100 |
commit | f3849ee5c7061fc41e42a506fa562272cd38291c (patch) | |
tree | 9e1e9861a88226da943c9964b25fa5e05a61036d /src | |
parent | 062d78eaf4ad1bc78ff03fc5d6831df26b558691 (diff) | |
download | stylish-haskell-f3849ee5c7061fc41e42a506fa562272cd38291c.tar.gz |
Small fixes for #34
Diffstat (limited to 'src')
-rw-r--r-- | src/Language/Haskell/Stylish/Step/LanguagePragmas.hs | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/Language/Haskell/Stylish/Step/LanguagePragmas.hs b/src/Language/Haskell/Stylish/Step/LanguagePragmas.hs index 48db19b..209b2f2 100644 --- a/src/Language/Haskell/Stylish/Step/LanguagePragmas.hs +++ b/src/Language/Haskell/Stylish/Step/LanguagePragmas.hs @@ -59,25 +59,30 @@ compactPragmas columns pragmas' = wrap columns "{-# LANGUAGE" 13 $ compactLinePragmas :: Int -> [String] -> Lines compactLinePragmas _ [] = [] compactLinePragmas columns pragmas' = - let maxWidth = columns - 14 - prags = map truncateComma $ wrap maxWidth "" 1 $ - map (++ ",") (init pragmas') ++ [last pragmas'] - longest = maximum $ map length prags - in map (wrapLANGUAGE . padRight longest) prags + let maxWidth = columns - 16 + longest = maximum $ map length prags + prags = map truncateComma $ wrap maxWidth "" 1 $ + map (++ ",") (init pragmas') ++ [last pragmas'] + in map (wrapLanguage . padRight longest) prags where - wrapLANGUAGE ps = "{-# LANGUAGE" ++ ps ++ " #-}" + wrapLanguage ps = "{-# LANGUAGE" ++ ps ++ " #-}" + +-------------------------------------------------------------------------------- truncateComma :: String -> String -truncateComma "" = "" +truncateComma "" = "" truncateComma xs | last xs == ',' = init xs | otherwise = xs + +-------------------------------------------------------------------------------- prettyPragmas :: Int -> Int -> Style -> [String] -> Lines -prettyPragmas _ longest Vertical = verticalPragmas longest -prettyPragmas columns _ Compact = compactPragmas columns +prettyPragmas _ longest Vertical = verticalPragmas longest +prettyPragmas columns _ Compact = compactPragmas columns prettyPragmas columns _ CompactLine = compactLinePragmas columns + -------------------------------------------------------------------------------- -- | Filter redundant (and duplicate) pragmas out of the groups. As a side -- effect, we also sort the pragmas in their group... |