on master help sign in
Support empty data declarations
commitb3ebe87bf3c12b7e7b034b79fd17d2355a022eb4 authorsphaso <sphaso@gmail.com> dateSat 22 Jun 2019, 12:11 (7 years ago) parent4f6b617
3 files changed+17−11
data/examples/declaration/data/empty-out.hs+2 data/examples/declaration/data/empty.hs+3 src/Ormolu/Printer/Meat/Declaration/Data.hs+12−11
data/examples/declaration/data/empty-out.hsnew file+2
@@ -0,0 +1,2 @@
1+{-# LANGUAGE EmptyDataDecls #-}
2+data Foo
data/examples/declaration/data/empty.hsnew file+3
@@ -0,0 +1,3 @@
1+{-# LANGUAGE EmptyDataDecls #-}
2+
3+data Foo
src/Ormolu/Printer/Meat/Declaration/Data.hs+12−11
@@ -43,17 +43,18 @@ p_dataDecl style name tpats HsDataDefn {..} = do
4343 txt ":: "
4444 located k p_hsType
4545 let gadt = isJust dd_kindSig || any (isGadt . unLoc) dd_cons
46− if gadt
47− then do
48− txt " where"
49− newline
50− inci $ newlineSep (sitcc . located' p_conDecl) dd_cons
51− else switchLayout (combineSrcSpans' (getLoc name :| (getLoc <$> dd_cons))) $ do
52− breakpoint
53− inci $ do
54− txt "= "
55− let sep = vlayout (txt " | ") (txt "| ")
56− velt $ withSep sep (sitcc . located' p_conDecl) dd_cons
46+ unless (null dd_cons) $
47+ if gadt
48+ then do
49+ txt " where"
50+ newline
51+ inci $ newlineSep (sitcc . located' p_conDecl) dd_cons
52+ else switchLayout (combineSrcSpans' (getLoc name :| (getLoc <$> dd_cons))) $
53+ inci $ do
54+ breakpoint
55+ txt "= "
56+ let sep = vlayout (txt " | ") (txt "| ")
57+ velt $ withSep sep (sitcc . located' p_conDecl) dd_cons
5758 newline
5859 inci . located dd_derivs $ \xs ->
5960 forM_ xs (line . located' p_hsDerivingClause)