Skip to content

Commit 4ec5c50

Browse files
authored
Keep wildcard if present in IEThingWith
This is necessary to export pattern synonyms bundled with a type
1 parent 2d54b73 commit 4ec5c50

File tree

2 files changed

+17
-2
lines changed
  • lib/Language/Haskell/Stylish/Step
  • tests/Language/Haskell/Stylish/Step/ModuleHeader

2 files changed

+17
-2
lines changed

lib/Language/Haskell/Stylish/Step/Imports.hs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,11 +323,14 @@ printImport _ (IEModuleContents _ (L _ m)) = do
323323
putText "module"
324324
space
325325
putText (moduleNameString m)
326-
printImport separateLists (IEThingWith _ name _wildcard imps _) = do
326+
printImport separateLists (IEThingWith _ name wildcard imps _) = do
327327
printIeWrappedName name
328328
when separateLists space
329+
let ellipsis = case wildcard of
330+
IEWildcard _position -> [putText ".."]
331+
NoIEWildcard -> []
329332
parenthesize $
330-
sep (comma >> space) (printIeWrappedName <$> imps)
333+
sep (comma >> space) (ellipsis <> fmap printIeWrappedName imps)
331334
printImport _ (IEGroup _ _ _ ) =
332335
error "Language.Haskell.Stylish.Printer.Imports.printImportExport: unhandled case 'IEGroup'"
333336
printImport _ (IEDoc _ _) =

tests/Language/Haskell/Stylish/Step/ModuleHeader/Tests.hs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ tests = testGroup "Language.Haskell.Stylish.Printer.ModuleHeader"
3636
, testCase "Does not sort" ex16
3737
, testCase "Repects separate_lists" ex17
3838
, testCase "Indents absent export list with break_only_where" ex18
39+
, testCase "Respects bundled patterns" ex19
3940
]
4041

4142
--------------------------------------------------------------------------------
@@ -319,3 +320,14 @@ ex18 = assertSnippet (step defaultConfig {breakOnlyWhere = True})
319320
[ "module Foo"
320321
, " where"
321322
]
323+
324+
ex19 :: Assertion
325+
ex19 = assertSnippet (step defaultConfig)
326+
[ "{-# LANGUAGE PatternSynonyms #-}"
327+
, "module Foo (Bar (.., Baz)) where"
328+
]
329+
[ "{-# LANGUAGE PatternSynonyms #-}"
330+
, "module Foo"
331+
, " ( Bar (.., Baz)"
332+
, " ) where"
333+
]

0 commit comments

Comments
 (0)