1
1
mirror of https://github.com/google/ormolu.git synced 2025-01-05 22:16:03 +03:00

Support empty data declarations

This commit is contained in:
sphaso 2019-06-22 12:11:02 +02:00 committed by Mark Karpov
parent 4f6b6171ba
commit b3ebe87bf3
3 changed files with 17 additions and 11 deletions

View File

@ -0,0 +1,2 @@
{-# LANGUAGE EmptyDataDecls #-}
data Foo

View File

@ -0,0 +1,3 @@
{-# LANGUAGE EmptyDataDecls #-}
data Foo

View File

@ -43,17 +43,18 @@ p_dataDecl style name tpats HsDataDefn {..} = do
txt ":: "
located k p_hsType
let gadt = isJust dd_kindSig || any (isGadt . unLoc) dd_cons
if gadt
then do
txt " where"
newline
inci $ newlineSep (sitcc . located' p_conDecl) dd_cons
else switchLayout (combineSrcSpans' (getLoc name :| (getLoc <$> dd_cons))) $ do
breakpoint
inci $ do
txt "= "
let sep = vlayout (txt " | ") (txt "| ")
velt $ withSep sep (sitcc . located' p_conDecl) dd_cons
unless (null dd_cons) $
if gadt
then do
txt " where"
newline
inci $ newlineSep (sitcc . located' p_conDecl) dd_cons
else switchLayout (combineSrcSpans' (getLoc name :| (getLoc <$> dd_cons))) $
inci $ do
breakpoint
txt "= "
let sep = vlayout (txt " | ") (txt "| ")
velt $ withSep sep (sitcc . located' p_conDecl) dd_cons
newline
inci . located dd_derivs $ \xs ->
forM_ xs (line . located' p_hsDerivingClause)