summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorOndřej Janošík <j.ondra14@gmail.com>2015-07-09 09:55:14 +0200
committerOndřej Janošík <j.ondra14@gmail.com>2015-07-09 09:55:14 +0200
commit4d01890e8d7a25dd6ebd9c9e0606eb53c1006b98 (patch)
tree555dcd562a6c7f9d4bd1d989cd35670624e11ee5 /src
parentcdb0fb4569a8cdac86e797059b7e46abb6718f05 (diff)
downloadstylish-haskell-4d01890e8d7a25dd6ebd9c9e0606eb53c1006b98.tar.gz
Fix for imports with only instances
Diffstat (limited to 'src')
-rw-r--r--src/Language/Haskell/Stylish/Step/Imports.hs17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/Language/Haskell/Stylish/Step/Imports.hs b/src/Language/Haskell/Stylish/Step/Imports.hs
index 78c8878..a4602a4 100644
--- a/src/Language/Haskell/Stylish/Step/Imports.hs
+++ b/src/Language/Haskell/Stylish/Step/Imports.hs
@@ -127,10 +127,10 @@ prettyImport columns Align{..} padQualified padName longest imp =
else inlineWrap
where
inlineWrap = inlineWrapper
+ $ mapSpecs
$ withInit (++ ",")
- $ withHead ("(" ++)
- $ withLast (++ ")")
- $ specs
+ . withHead ("(" ++)
+ . withLast (++ ")")
inlineWrapper = case listAlign of
NewLine -> (inlineBase :) . wrapRest columns listPadding
@@ -140,9 +140,10 @@ prettyImport columns Align{..} padQualified padName longest imp =
. wrap columns inlineBase (afterAliasBaseLength + 1)
multilineWrap = multilineBase : (wrapRest 0 listPadding
- $ (withHead ("( " ++)
- $ withTail (", " ++)
- $ specs) ++ [")"])
+ $ (mapSpecs
+ $ withHead ("( " ++)
+ . withTail (", " ++))
+ ++ [")"])
inlineBase = base $ padImport $ importName imp
@@ -181,10 +182,10 @@ prettyImport columns Align{..} padQualified padName longest imp =
| padQualified = [" "]
| otherwise = []
- specs = case importSpecs of
+ mapSpecs f = case importSpecs of
Nothing -> [] -- Import everything
Just [] -> ["()"] -- Instance only imports
- Just is -> map prettyImportSpec is
+ Just is -> f $ map prettyImportSpec is
--------------------------------------------------------------------------------