summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorJasper Van der Jeugt <m@jaspervdj.be>2012-10-04 09:17:03 +0900
committerJasper Van der Jeugt <m@jaspervdj.be>2012-10-04 09:17:03 +0900
commitf603a1d55e7fa8570d0c02e236a1729031bfb6a0 (patch)
treee5fbcdff610e5dd97544b1d5f8e31487fc5c6420 /src
parentdb21c8d5a1cc87beaa666cfb792a4b3625186509 (diff)
downloadstylish-haskell-f603a1d55e7fa8570d0c02e236a1729031bfb6a0.tar.gz
Fix issue with instance only imports
Closes #18
Diffstat (limited to 'src')
-rw-r--r--src/Language/Haskell/Stylish/Step/Imports.hs18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/Language/Haskell/Stylish/Step/Imports.hs b/src/Language/Haskell/Stylish/Step/Imports.hs
index ea0b8a4..9d91995 100644
--- a/src/Language/Haskell/Stylish/Step/Imports.hs
+++ b/src/Language/Haskell/Stylish/Step/Imports.hs
@@ -112,11 +112,15 @@ prettyImport :: Int -> Bool -> Bool -> Int -> H.ImportDecl l -> [String]
prettyImport columns padQualified padName longest imp =
wrap columns base (length base + 2) $
(if hiding then ("hiding" :) else id) $
- withInit (++ ",") $
- withHead ("(" ++) $
- withLast (++ ")") $
- map prettyImportSpec $
- importSpecs
+ case importSpecs of
+ Nothing -> [] -- Import everything
+ Just [] -> ["()"] -- Instance only imports
+ Just is ->
+ withInit (++ ",") $
+ withHead ("(" ++) $
+ withLast (++ ")") $
+ map prettyImportSpec $
+ is
where
base = unwords $ concat
[ ["import"]
@@ -128,8 +132,8 @@ prettyImport columns padQualified padName longest imp =
]
(hiding, importSpecs) = case H.importSpecs imp of
- Just (H.ImportSpecList _ h l) -> (h, l)
- _ -> (False, [])
+ Just (H.ImportSpecList _ h l) -> (h, Just l)
+ _ -> (False, Nothing)
hasExtras = isJust (H.importAs imp) || isJust (H.importSpecs imp)