diff options
author | Jasper Van der Jeugt <m@jaspervdj.be> | 2012-08-08 15:31:32 +0900 |
---|---|---|
committer | Jasper Van der Jeugt <m@jaspervdj.be> | 2012-08-08 15:31:35 +0900 |
commit | 57f7629214e89f58232b4c822e20be704a212cdf (patch) | |
tree | bf7623a207303dd89dc2ade1461e09954505b67d /src | |
parent | f8c0ae3f0183415be467ae71efb5e8a9fbeceddf (diff) | |
download | stylish-haskell-57f7629214e89f58232b4c822e20be704a212cdf.tar.gz |
Fix missing space in: import Foo (Bar (..))
Diffstat (limited to 'src')
-rw-r--r-- | src/StylishHaskell/Step/Imports.hs | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/StylishHaskell/Step/Imports.hs b/src/StylishHaskell/Step/Imports.hs index 5b1198f..5783c58 100644 --- a/src/StylishHaskell/Step/Imports.hs +++ b/src/StylishHaskell/Step/Imports.hs @@ -91,6 +91,23 @@ sortImportSpecs imp = imp {H.importSpecs = fmap sort $ H.importSpecs imp} -------------------------------------------------------------------------------- +-- | By default, haskell-src-exts pretty-prints +-- +-- > import Foo (Bar(..)) +-- +-- but we want +-- +-- > import Foo (Bar (..)) +-- +-- instead. +prettyImportSpec :: H.ImportSpec l -> String +prettyImportSpec (H.IThingAll _ n) = H.prettyPrint n ++ " (..)" +prettyImportSpec (H.IThingWith _ n cns) = H.prettyPrint n ++ " (" ++ + intercalate ", " (map H.prettyPrint cns) ++ ")" +prettyImportSpec x = H.prettyPrint x + + +-------------------------------------------------------------------------------- prettyImport :: Int -> Bool -> Bool -> Int -> H.ImportDecl l -> String prettyImport columns padQualified padName longest imp = intercalate "\n" $ @@ -99,7 +116,7 @@ prettyImport columns padQualified padName longest imp = withInit (++ ",") $ withHead ("(" ++) $ withLast (++ ")") $ - map H.prettyPrint $ + map prettyImportSpec $ importSpecs where base = unwords $ concat |