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:
parent
4f6b6171ba
commit
b3ebe87bf3
2
data/examples/declaration/data/empty-out.hs
Normal file
2
data/examples/declaration/data/empty-out.hs
Normal file
@ -0,0 +1,2 @@
|
||||
{-# LANGUAGE EmptyDataDecls #-}
|
||||
data Foo
|
3
data/examples/declaration/data/empty.hs
Normal file
3
data/examples/declaration/data/empty.hs
Normal file
@ -0,0 +1,3 @@
|
||||
{-# LANGUAGE EmptyDataDecls #-}
|
||||
|
||||
data Foo
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user