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:
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 ":: "
|
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)
|
||||||
|
Loading…
Reference in New Issue
Block a user