on master help sign in
Fix mixing names with double dot in export lists
commit180df38a713e95a429456895c603061fe7ce4087 authorMitchell Rosen <mitchellwrosen@gmail.com> dateSat 27 Jul 2019, 17:37 (7 years ago) parent81b2919
4 files changed+48−9
data/examples/module-header/double-dot-with-names-out.hs+22 data/examples/module-header/double-dot-with-names.hs+17 src/Ormolu/Printer/Meat/Common.hs−6 src/Ormolu/Printer/Meat/ImportExport.hs+9−3
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
1010 , p_rdrName
1111 , doesNotNeedExtraParens
1212 , p_qualName
13− , p_ieWildcard
1413 , p_infixDefHelper
1514 )
1615where
@@ -108,11 +107,6 @@ p_qualName mname occName = do
108107 txt "."
109108 atom occName
110109
111−p_ieWildcard :: IEWildcard -> R ()
112−p_ieWildcard = \case
113− NoIEWildcard -> return ()
114− IEWildcard n -> parens (atom n)
115−
116110-- | A helper for formatting infix constructions in lhs of definitions.
117111
118112p_infixDefHelper
src/Ormolu/Printer/Meat/ImportExport.hs+9−3
@@ -66,12 +66,18 @@ p_lie = \case
6666 located l1 p_ieWrappedName
6767 txt " (..)"
6868 IEThingWith NoExt l1 w xs _ -> sitcc $ do
69+ -- XXX I have no idea what field labels are in this context.
6970 located l1 p_ieWrappedName
7071 breakpoint
71− -- XXX I have no idea what field labels are in this context.
7272 inci $ do
73− p_ieWildcard w
74− parens . velt $ withSep comma (located' p_ieWrappedName) xs
73+ let names :: [R ()]
74+ names = 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
7581 IEModuleContents NoExt l1 -> located l1 p_hsmodName
7682 -- XXX I have no idea what these things are for.
7783 IEGroup NoExt _ _ -> return ()