From f3849ee5c7061fc41e42a506fa562272cd38291c Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Wed, 18 Dec 2013 11:37:54 +0100 Subject: Small fixes for #34 --- .../Haskell/Stylish/Step/LanguagePragmas.hs | 23 +++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'src') 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... -- cgit v1.2.3