1
1
mirror of https://github.com/google/ormolu.git synced 2025-01-07 15:50:27 +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 ":: " txt ":: "
located k p_hsType located k p_hsType
let gadt = isJust dd_kindSig || any (isGadt . unLoc) dd_cons let gadt = isJust dd_kindSig || any (isGadt . unLoc) dd_cons
if gadt unless (null dd_cons) $
then do if gadt
txt " where" then do
newline txt " where"
inci $ newlineSep (sitcc . located' p_conDecl) dd_cons newline
else switchLayout (combineSrcSpans' (getLoc name :| (getLoc <$> dd_cons))) $ do inci $ newlineSep (sitcc . located' p_conDecl) dd_cons
breakpoint else switchLayout (combineSrcSpans' (getLoc name :| (getLoc <$> dd_cons))) $
inci $ do inci $ do
txt "= " breakpoint
let sep = vlayout (txt " | ") (txt "| ") txt "= "
velt $ withSep sep (sitcc . located' p_conDecl) dd_cons let sep = vlayout (txt " | ") (txt "| ")
velt $ withSep sep (sitcc . located' p_conDecl) dd_cons
newline newline
inci . located dd_derivs $ \xs -> inci . located dd_derivs $ \xs ->
forM_ xs (line . located' p_hsDerivingClause) forM_ xs (line . located' p_hsDerivingClause)