diff options
Diffstat (limited to 'lib/Language/Haskell/Stylish/Step/Imports.hs')
-rw-r--r-- | lib/Language/Haskell/Stylish/Step/Imports.hs | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/Language/Haskell/Stylish/Step/Imports.hs b/lib/Language/Haskell/Stylish/Step/Imports.hs index 78912d6..38ced99 100644 --- a/lib/Language/Haskell/Stylish/Step/Imports.hs +++ b/lib/Language/Haskell/Stylish/Step/Imports.hs @@ -42,6 +42,7 @@ data Options = Options , emptyListAlign :: EmptyListAlign , listPadding :: ListPadding , separateLists :: Bool + , spaceSurround :: Bool } deriving (Eq, Show) defaultOptions :: Options @@ -52,6 +53,7 @@ defaultOptions = Options , emptyListAlign = Inherit , listPadding = LPConstant 4 , separateLists = True + , spaceSurround = False } data ListPadding @@ -280,21 +282,21 @@ prettyImport columns Options{..} padQualified padName longest imp inlineWrap = inlineWrapper $ mapSpecs $ withInit (++ ",") - . withHead ("(" ++) - . withLast (++ ")") + . withHead (("(" ++ maybeSpace) ++) + . withLast (++ (maybeSpace ++ ")")) inlineWrapper = case listAlign of NewLine -> (paddedNoSpecBase :) . wrapRest columns listPadding' WithAlias -> wrap columns paddedBase (inlineBaseLength + 1) -- Add 1 extra space to ensure same padding as in original code. - AfterAlias -> withTail (' ' :) + AfterAlias -> withTail ((' ' : maybeSpace) ++) . wrap columns paddedBase (afterAliasBaseLength + 1) inlineWithBreakWrap = paddedNoSpecBase : wrapRest columns listPadding' ( mapSpecs $ withInit (++ ",") - . withHead ("(" ++) - . withLast (++ ")")) + . withHead (("(" ++ maybeSpace) ++) + . withLast (++ (maybeSpace ++ ")"))) inlineToMultilineWrap | length inlineWithBreakWrap > 2 @@ -370,6 +372,10 @@ prettyImport columns Options{..} padQualified padName longest imp Just [] -> ["()"] -- Instance only imports Just is -> f $ map (prettyImportSpec separateLists) is + maybeSpace = case spaceSurround of + True -> " " + False -> "" + -------------------------------------------------------------------------------- prettyImportGroup :: Int -> Options -> Bool -> Int |