on master help sign in
Keep comma on multiple GADT declaration
174a084sphaso
data/examples/declaration/data/gadt/multiple-declaration-out.hsnew file+15
@@ -0,0 +1,15 @@
1+data GADT0 a where
2+ GADT01, GADT02 :: Int -> GADT0 a
3+
4+data GADT1 a where
5+ GADT11
6+ , GADT12
7+ :: Int
8+ -> GADT1 a
9+
10+data GADT2 a where
11+ GADT21
12+ , GADT21
13+ , GADT22
14+ :: Int
15+ -> GADT2 a
data/examples/declaration/data/gadt/multiple-declaration.hsnew file+11
@@ -0,0 +1,11 @@
1+data GADT0 a where
2+ GADT01, GADT02 :: Int -> GADT0 a
3+
4+data GADT1 a where
5+ GADT11
6+ , GADT12 :: Int -> GADT1 a
7+
8+data GADT2 a where
9+ GADT21
10+ , GADT21
11+ , GADT22 :: Int -> GADT2 a
src/Ormolu/Printer/Meat/Declaration/Data.hs+9−1
@@ -69,7 +69,15 @@ p_dataDecl _ _ _ _ (XHsDataDefn NoExt) = notImplemented "XHsDataDefn"
69p_conDecl :: ConDecl GhcPs -> R ()
69p_conDecl :: ConDecl GhcPs -> R ()
70p_conDecl = \case
70p_conDecl = \case
71 ConDeclGADT {..} -> do
71 ConDeclGADT {..} -> do
72− spaceSep p_rdrName con_names
72+ case con_names of
73+ [] -> return ()
74+ (c:cs) -> do
75+ p_rdrName c
76+ unless (null cs) $ do
77+ breakpoint'
78+ inci $ do
79+ comma
80+ velt $ withSep comma p_rdrName cs
73 breakpoint
81 breakpoint
74 inci $ do
82 inci $ do
75 txt ":: "
83 txt ":: "