on master help sign in
Fix mixing names with double dot in export lists
180df38Mitchell Rosen
data/examples/module-header/double-dot-with-names-out.hsnew file+22
@@ -0,0 +1,22 @@
1+{-# LANGUAGE PatternSynonyms #-}
2+
3+module ExportSyntax
4+ ( A (.., NoA)
5+ , Q (F, ..)
6+ , G (T, .., U)
7+ )
8+where
9+
10+data A = A | B
11+
12+pattern NoA = B
13+
14+data Q a = Q a
15+
16+pattern F a = Q a
17+
18+data G = G | H
19+
20+pattern T = G
21+
22+pattern U = H
data/examples/module-header/double-dot-with-names.hsnew file+17
@@ -0,0 +1,17 @@
1+{-# LANGUAGE PatternSynonyms #-}
2+
3+module ExportSyntax ( A(.., NoA), Q(F,..), G(T,..,U)) where
4+
5+data A = A | B
6+
7+pattern NoA = B
8+
9+data Q a = Q a
10+
11+pattern F a = Q a
12+
13+data G = G | H
14+
15+pattern T = G
16+
17+pattern U = H
src/Ormolu/Printer/Meat/Common.hs−6
@@ -10,7 +10,6 @@ module Ormolu.Printer.Meat.Common
10 , p_rdrName
10 , p_rdrName
11 , doesNotNeedExtraParens
11 , doesNotNeedExtraParens
12 , p_qualName
12 , p_qualName
13− , p_ieWildcard
14 , p_infixDefHelper
13 , p_infixDefHelper
15 )
14 )
16where
15where
@@ -108,11 +107,6 @@ p_qualName mname occName = do
108 txt "."
107 txt "."
109 atom occName
108 atom occName
110
109
111−p_ieWildcard :: IEWildcard -> R ()
112−p_ieWildcard = \case
113− NoIEWildcard -> return ()
114− IEWildcard n -> parens (atom n)
115−
116-- | A helper for formatting infix constructions in lhs of definitions.
110-- | A helper for formatting infix constructions in lhs of definitions.
117
111
118p_infixDefHelper
112p_infixDefHelper
src/Ormolu/Printer/Meat/ImportExport.hs+9−3
@@ -66,12 +66,18 @@ p_lie = \case
66 located l1 p_ieWrappedName
66 located l1 p_ieWrappedName
67 txt " (..)"
67 txt " (..)"
68 IEThingWith NoExt l1 w xs _ -> sitcc $ do
68 IEThingWith NoExt l1 w xs _ -> sitcc $ do
69+ -- XXX I have no idea what field labels are in this context.
69 located l1 p_ieWrappedName
70 located l1 p_ieWrappedName
70 breakpoint
71 breakpoint
71− -- XXX I have no idea what field labels are in this context.
72 inci $ do
72 inci $ do
73− p_ieWildcard w
73+ let names :: [R ()]
74+ names = located' p_ieWrappedName <$> xs
74− parens . velt $ withSep comma (located' p_ieWrappedName) xs
75+ parens . velt . withSep comma id $
76+ case w of
77+ NoIEWildcard -> names
78+ IEWildcard n ->
79+ let (before, after) = splitAt n names
80+ in before ++ [txt ".."] ++ after
75 IEModuleContents NoExt l1 -> located l1 p_hsmodName
81 IEModuleContents NoExt l1 -> located l1 p_hsmodName
76 -- XXX I have no idea what these things are for.
82 -- XXX I have no idea what these things are for.
77 IEGroup NoExt _ _ -> return ()
83 IEGroup NoExt _ _ -> return ()