on master help sign in
Keep comma on multiple GADT declaration
commit174a0847d46c545d9a7cb7cf2debf56c9cf4dcf5 authorsphaso <sphaso@gmail.com> dateSat 20 Jul 2019, 17:09 (7 years ago) parent8d52d87
3 files changed+35−1
data/examples/declaration/data/gadt/multiple-declaration-out.hs+15 data/examples/declaration/data/gadt/multiple-declaration.hs+11 src/Ormolu/Printer/Meat/Declaration/Data.hs+9−1
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"
6969p_conDecl :: ConDecl GhcPs -> R ()
7070p_conDecl = \case
7171 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
7381 breakpoint
7482 inci $ do
7583 txt ":: "