on master help sign in
Fix printing of TH brackets
a0aa410Utku Demir
data/examples/declaration/data/gadt-syntax-out.hs+1−2
@@ -1,3 +1,2 @@
1{-# LANUGAGE GADTSyntax #-}
1{-# LANUGAGE GADTSyntax #-}
2−data Foo where
3− MKFoo :: a -> (a -> Bool) -> Foo
2+data Foo where MKFoo :: a -> (a -> Bool) -> Foo
data/examples/declaration/splice/bracket-out.hs+7−8
@@ -2,23 +2,22 @@
2
2
3foo =
3foo =
4 [e|
4 [e|
5− foo bar
5+ foo bar
6− |]
6+ |]
7
7
8foo =
8foo =
9 [e|
9 [e|
10− foo bar
10+ foo bar
11− |]
11+ |]
12
12
13foo = [t|Char|]
13foo = [t|Char|]
14
14
15foo =
15foo =
16 [d|
16 [d|
17− foo :: Int -> Char
17+ foo :: Int -> Char
18−
19− bar = 42
20
18
19+ bar = 42
21− |]
20+ |]
22
21
23foo =
22foo =
24 [||
23 [||
data/examples/declaration/splice/splice-decl-out.hs+18
@@ -15,3 +15,21 @@ foo bar
15-- TemplateHaskell allows Q () at the top level
15-- TemplateHaskell allows Q () at the top level
16do
16do
17 pure []
17 pure []
18+
19+$(do [d|baz = baz|])
20+
21+[d|data T a where Foo :: T ()|]
22+
23+[d|
24+ data T = T
25+ deriving (Eq, Ord, Enum, Bounded, Show)
26+ |]
27+
28+$(singletons [d|data T = T deriving (Eq, Ord, Enum, Bounded, Show)|])
29+
30+$( singletons
31+ [d|
32+ data T = T
33+ deriving (Eq, Ord, Enum, Bounded, Show)
34+ |]
35+ )
data/examples/declaration/splice/splice-decl.hs+17
@@ -15,3 +15,20 @@ foo bar
15-- TemplateHaskell allows Q () at the top level
15-- TemplateHaskell allows Q () at the top level
16do
16do
17 pure []
17 pure []
18+
19+$( do [d| baz = baz |] )
20+
21+[d| data T a where Foo :: T () |]
22+
23+[d|
24+ data T = T
25+ deriving (Eq, Ord, Enum, Bounded, Show)
26+ |]
27+
28+$(singletons [d| data T = T deriving (Eq, Ord, Enum, Bounded, Show) |])
29+
30+$(singletons [d|
31+ data T = T
32+ deriving (Eq, Ord, Enum, Bounded, Show)
33+ |])
34+
data/examples/declaration/value/function/do-out.hs+1−2
@@ -65,8 +65,7 @@ g = unFoo
65 ret
65 ret
66
66
67main =
67main =
68− do
69− stuff
68+ do stuff
70 `finally` do
69 `finally` do
71 recover
70 recover
72
71
data/examples/declaration/value/function/operators-out.hs+1−2
@@ -24,8 +24,7 @@ foo =
24 + 2
24 + 2
25
25
26main =
26main =
27− do
28− stuff
27+ do stuff
29 `finally` do
28 `finally` do
30 recover
29 recover
31
30
data/examples/declaration/warning/warning-multiline-out.hs+1
@@ -5,5 +5,6 @@
5 "Really bad!"
5 "Really bad!"
6 ]
6 ]
7 #-}
7 #-}
8+
8test :: IO ()
9test :: IO ()
9test = pure ()
10test = pure ()
data/examples/declaration/warning/warning-single-line-out.hs+2−1
@@ -1,4 +1,5 @@
1−{-# WARNING test "This is a warning" #-}
2{-# DEPRECATED test, foo "This is a deprecation" #-}
1{-# DEPRECATED test, foo "This is a deprecation" #-}
2+
3+{-# WARNING test "This is a warning" #-}
3test :: IO ()
4test :: IO ()
4test = pure ()
5test = pure ()
data/examples/declaration/warning/warning-single-line.hs+1−1
@@ -1,5 +1,5 @@
1−{-# WARNING test ["This is a warning" ] #-}
2{-# Deprecated test, foo "This is a deprecation"
1{-# Deprecated test, foo "This is a deprecation"
3 #-}
2 #-}
3+{-# WARNING test ["This is a warning" ] #-}
4test :: IO ()
4test :: IO ()
5test = pure ()
5test = pure ()
src/Ormolu/Printer/Meat/Declaration.hs+7−4
@@ -37,9 +37,9 @@ p_hsDecls style decls =
37 case md of
37 case md of
38 Nothing -> located d pDecl
38 Nothing -> located d pDecl
39 Just d' ->
39 Just d' ->
40− if separatedDecls (unLoc d) (unLoc d')
40+ line $ if separatedDecls (unLoc d) (unLoc d')
41− then line (located d pDecl)
41+ then line (located d pDecl)
42− else located d pDecl
42+ else located d pDecl
43 where
43 where
44 pDecl = p_hsDecl style
44 pDecl = p_hsDecl style
45
45
@@ -118,6 +118,7 @@ isPragma = \case
118 SCCPragma n -> Just n
118 SCCPragma n -> Just n
119 AnnTypePragma n -> Just n
119 AnnTypePragma n -> Just n
120 AnnValuePragma n -> Just n
120 AnnValuePragma n -> Just n
121+ WarningPragma n -> Just n
121 _ -> Nothing
122 _ -> Nothing
122
123
123pattern TypeSignature
124pattern TypeSignature
@@ -128,7 +129,8 @@ pattern TypeSignature
128 , AnnTypePragma
129 , AnnTypePragma
129 , AnnValuePragma
130 , AnnValuePragma
130 , PatternSignature
131 , PatternSignature
132+ , Pattern
131− , Pattern :: RdrName -> HsDecl GhcPs
133+ , WarningPragma :: RdrName -> HsDecl GhcPs
132pattern TypeSignature n <- (sigRdrName -> Just n)
134pattern TypeSignature n <- (sigRdrName -> Just n)
133pattern FunctionBody n <- ValD NoExt (FunBind NoExt (L _ n) _ _ _)
135pattern FunctionBody n <- ValD NoExt (FunBind NoExt (L _ n) _ _ _)
134pattern InlinePragma n <- SigD NoExt (InlineSig NoExt (L _ n) _)
136pattern InlinePragma n <- SigD NoExt (InlineSig NoExt (L _ n) _)
@@ -138,6 +140,7 @@ pattern AnnTypePragma n <- AnnD NoExt (HsAnnotation NoExt _ (TypeAnnProvenance (
138pattern AnnValuePragma n <- AnnD NoExt (HsAnnotation NoExt _ (ValueAnnProvenance (L _ n)) _)
140pattern AnnValuePragma n <- AnnD NoExt (HsAnnotation NoExt _ (ValueAnnProvenance (L _ n)) _)
139pattern PatternSignature n <- SigD NoExt (PatSynSig NoExt ((L _ n):_) _)
141pattern PatternSignature n <- SigD NoExt (PatSynSig NoExt ((L _ n):_) _)
140pattern Pattern n <- ValD NoExt (PatSynBind NoExt (PSB _ (L _ n) _ _ _))
142pattern Pattern n <- ValD NoExt (PatSynBind NoExt (PSB _ (L _ n) _ _ _))
143+pattern WarningPragma n <- WarningD NoExt (Warnings NoExt _ [(L _ (Warning NoExt [(L _ n)] _))])
141
144
142sigRdrName :: HsDecl GhcPs -> Maybe RdrName
145sigRdrName :: HsDecl GhcPs -> Maybe RdrName
143sigRdrName (SigD NoExt (TypeSig NoExt ((L _ n):_) _)) = Just n
146sigRdrName (SigD NoExt (TypeSig NoExt ((L _ n):_) _)) = Just n
src/Ormolu/Printer/Meat/Declaration/Annotation.hs+1−1
@@ -14,7 +14,7 @@ import Ormolu.Utils
14
14
15p_annDecl :: AnnDecl GhcPs -> R ()
15p_annDecl :: AnnDecl GhcPs -> R ()
16p_annDecl = \case
16p_annDecl = \case
17− HsAnnotation NoExt _ annProv expr -> line . pragma "ANN" . inci $ do
17+ HsAnnotation NoExt _ annProv expr -> pragma "ANN" . inci $ do
18 p_annProv annProv
18 p_annProv annProv
19 breakpoint
19 breakpoint
20 located expr p_hsExpr
20 located expr p_hsExpr
src/Ormolu/Printer/Meat/Declaration/Class.hs+1−3
@@ -64,13 +64,11 @@ p_classDecl ctx name tvars fixity fdeps csigs cdefs cats catdefs = do
64 ) <$> catdefs
64 ) <$> catdefs
65 allDecls =
65 allDecls =
66 snd <$> sortBy (comparing fst) (sigs <> vals <> tyFams <> tyFamDefs)
66 snd <$> sortBy (comparing fst) (sigs <> vals <> tyFams <> tyFamDefs)
67− if not (null allDecls)
67+ unless (null allDecls) $ do
68− then do
69 txt " where"
68 txt " where"
70 newline -- Ensure line is added after where clause.
69 newline -- Ensure line is added after where clause.
71 newline -- Add newline before first declaration.
70 newline -- Add newline before first declaration.
72 inci (p_hsDecls Associated allDecls)
71 inci (p_hsDecls Associated allDecls)
73− else newline
74
72
75p_classContext :: LHsContext GhcPs -> R ()
73p_classContext :: LHsContext GhcPs -> R ()
76p_classContext ctx = unless (null (unLoc ctx)) $ do
74p_classContext ctx = unless (null (unLoc ctx)) $ do
src/Ormolu/Printer/Meat/Declaration/Data.hs+5−4
@@ -51,7 +51,7 @@ p_dataDecl style name tpats fixity HsDataDefn {..} = do
51 if gadt
51 if gadt
52 then do
52 then do
53 txt " where"
53 txt " where"
54− newline
54+ breakpoint
55 inci . sitcc $ sep newline (sitcc . located' p_conDecl) dd_cons
55 inci . sitcc $ sep newline (sitcc . located' p_conDecl) dd_cons
56 else switchLayout (getLoc name : (getLoc <$> dd_cons)) $
56 else switchLayout (getLoc name : (getLoc <$> dd_cons)) $
57 inci $ do
57 inci $ do
@@ -59,9 +59,10 @@ p_dataDecl style name tpats fixity HsDataDefn {..} = do
59 txt "= "
59 txt "= "
60 let s = vlayout (txt " | ") (newline >> txt "| ")
60 let s = vlayout (txt " | ") (newline >> txt "| ")
61 sep s (sitcc . located' p_conDecl) dd_cons
61 sep s (sitcc . located' p_conDecl) dd_cons
62− newline
62+
63+ unless (null $ unLoc dd_derivs) breakpoint
63− inci . located dd_derivs $ \xs ->
64+ inci . located dd_derivs $ \xs -> do
64− forM_ xs (line . located' p_hsDerivingClause)
65+ sep newline (located' p_hsDerivingClause) xs
65p_dataDecl _ _ _ _ (XHsDataDefn NoExt) = notImplemented "XHsDataDefn"
66p_dataDecl _ _ _ _ (XHsDataDefn NoExt) = notImplemented "XHsDataDefn"
66
67
67p_conDecl :: ConDecl GhcPs -> R ()
68p_conDecl :: ConDecl GhcPs -> R ()
src/Ormolu/Printer/Meat/Declaration/Default.hs+1−1
@@ -13,7 +13,7 @@ import Ormolu.Utils
13
13
14p_defaultDecl :: DefaultDecl GhcPs -> R ()
14p_defaultDecl :: DefaultDecl GhcPs -> R ()
15p_defaultDecl = \case
15p_defaultDecl = \case
16− DefaultDecl NoExt ts -> line $ do
16+ DefaultDecl NoExt ts -> do
17 txt "default"
17 txt "default"
18 breakpoint
18 breakpoint
19 inci . parens . sitcc $
19 inci . parens . sitcc $
src/Ormolu/Printer/Meat/Declaration/Foreign.hs+2−2
@@ -19,10 +19,10 @@ import Ormolu.Utils
19
19
20p_foreignDecl :: ForeignDecl GhcPs -> R ()
20p_foreignDecl :: ForeignDecl GhcPs -> R ()
21p_foreignDecl = \case
21p_foreignDecl = \case
22− fd@ForeignImport {fd_fi} -> line $ do
22+ fd@ForeignImport {fd_fi} -> do
23 p_foreignImport fd_fi
23 p_foreignImport fd_fi
24 p_foreignTypeSig fd
24 p_foreignTypeSig fd
25− fd@ForeignExport {fd_fe} -> line $ do
25+ fd@ForeignExport {fd_fe} -> do
26 p_foreignExport fd_fe
26 p_foreignExport fd_fe
27 p_foreignTypeSig fd
27 p_foreignTypeSig fd
28 XForeignDecl {} -> notImplemented "XForeignDecl"
28 XForeignDecl {} -> notImplemented "XForeignDecl"
src/Ormolu/Printer/Meat/Declaration/Instance.hs+8−11
@@ -14,6 +14,7 @@ where
14
14
15import BasicTypes
15import BasicTypes
16import Control.Arrow
16import Control.Arrow
17+import Control.Monad
17import Data.Foldable
18import Data.Foldable
18import Data.List (sortBy)
19import Data.List (sortBy)
19import Data.Ord (comparing)
20import Data.Ord (comparing)
@@ -59,7 +60,6 @@ p_standaloneDerivDecl DerivDecl {..} = do
59 instTypes True
60 instTypes True
60 ViaStrategy (XHsImplicitBndrs NoExt) ->
61 ViaStrategy (XHsImplicitBndrs NoExt) ->
61 notImplemented "XHsImplicitBndrs"
62 notImplemented "XHsImplicitBndrs"
62− newline
63p_standaloneDerivDecl (XDerivDecl _) = notImplemented "XDerivDecl"
63p_standaloneDerivDecl (XDerivDecl _) = notImplemented "XDerivDecl"
64
64
65p_clsInstDecl :: ClsInstDecl GhcPs -> R ()
65p_clsInstDecl :: ClsInstDecl GhcPs -> R ()
@@ -87,15 +87,13 @@ p_clsInstDecl = \case
87 allDecls =
87 allDecls =
88 snd <$>
88 snd <$>
89 sortBy (comparing fst) (sigs <> vals <> tyFamInsts <> dataFamInsts)
89 sortBy (comparing fst) (sigs <> vals <> tyFamInsts <> dataFamInsts)
90− if null allDecls
90+ unless (null allDecls) $ do
91− then newline
92− else do
93− switchLayout [getLoc hsib_body] breakpoint
91+ switchLayout [getLoc hsib_body] breakpoint
94− inci $ do
92+ inci $ do
95− txt "where"
93+ txt "where"
96− newline -- Ensure line is added after where clause.
94+ newline -- Ensure line is added after where clause.
97− newline -- Add newline before first declaration.
95+ newline -- Add newline before first declaration.
98− p_hsDecls Associated allDecls
96+ p_hsDecls Associated allDecls
99 XHsImplicitBndrs NoExt -> notImplemented "XHsImplicitBndrs"
97 XHsImplicitBndrs NoExt -> notImplemented "XHsImplicitBndrs"
100 XClsInstDecl NoExt -> notImplemented "XClsInstDecl"
98 XClsInstDecl NoExt -> notImplemented "XClsInstDecl"
101
99
@@ -107,7 +105,6 @@ p_tyFamInstDecl style = \case
107 Free -> "type instance"
105 Free -> "type instance"
108 breakpoint
106 breakpoint
109 inci (p_tyFamInstEqn tfid_eqn)
107 inci (p_tyFamInstEqn tfid_eqn)
110− newline
111
108
112p_dataFamInstDecl :: FamilyStyle -> DataFamInstDecl GhcPs -> R ()
109p_dataFamInstDecl :: FamilyStyle -> DataFamInstDecl GhcPs -> R ()
113p_dataFamInstDecl style = \case
110p_dataFamInstDecl style = \case
src/Ormolu/Printer/Meat/Declaration/RoleAnnotation.hs+1−1
@@ -24,7 +24,7 @@ p_roleAnnot = \case
24 XRoleAnnotDecl _ -> notImplemented "XRoleAnnotDecl"
24 XRoleAnnotDecl _ -> notImplemented "XRoleAnnotDecl"
25
25
26p_roleAnnot' :: Located RdrName -> [Located (Maybe Role)] -> R ()
26p_roleAnnot' :: Located RdrName -> [Located (Maybe Role)] -> R ()
27−p_roleAnnot' l_name anns = line $ do
27+p_roleAnnot' l_name anns = do
28 txt "type role"
28 txt "type role"
29 breakpoint
29 breakpoint
30 inci $ do
30 inci $ do
src/Ormolu/Printer/Meat/Declaration/Rule.hs+1−1
@@ -20,7 +20,7 @@ import qualified Data.Text as T
20
20
21p_ruleDecls :: RuleDecls GhcPs -> R ()
21p_ruleDecls :: RuleDecls GhcPs -> R ()
22p_ruleDecls = \case
22p_ruleDecls = \case
23− HsRules NoExt _ xs -> line . pragma "RULES" . sitcc $
23+ HsRules NoExt _ xs -> pragma "RULES" . sitcc $
24 sep breakpoint (sitcc . located' p_ruleDecl) xs
24 sep breakpoint (sitcc . located' p_ruleDecl) xs
25 XRuleDecls NoExt -> notImplemented "XRuleDecls"
25 XRuleDecls NoExt -> notImplemented "XRuleDecls"
26
26
src/Ormolu/Printer/Meat/Declaration/Signature.hs+1−5
@@ -6,7 +6,6 @@
6
6
7module Ormolu.Printer.Meat.Declaration.Signature
7module Ormolu.Printer.Meat.Declaration.Signature
8 ( p_sigDecl
8 ( p_sigDecl
9− , p_sigDecl'
10 , p_typeAscription
9 , p_typeAscription
11 , p_activation
10 , p_activation
12 , visibleActivation
11 , visibleActivation
@@ -23,10 +22,7 @@ import Ormolu.Printer.Meat.Type
23import Ormolu.Utils
22import Ormolu.Utils
24
23
25p_sigDecl :: Sig GhcPs -> R ()
24p_sigDecl :: Sig GhcPs -> R ()
26−p_sigDecl = line . p_sigDecl'
25+p_sigDecl = \case
27−
28−p_sigDecl' :: Sig GhcPs -> R ()
29−p_sigDecl' = \case
30 TypeSig NoExt names hswc -> p_typeSig names hswc
26 TypeSig NoExt names hswc -> p_typeSig names hswc
31 PatSynSig NoExt names hsib -> p_patSynSig names hsib
27 PatSynSig NoExt names hsib -> p_patSynSig names hsib
32 ClassOpSig NoExt def names hsib -> p_classOpSig def names hsib
28 ClassOpSig NoExt def names hsib -> p_classOpSig def names hsib
src/Ormolu/Printer/Meat/Declaration/Splice.hs+1−1
@@ -12,5 +12,5 @@ import Ormolu.Utils
12
12
13p_spliceDecl :: SpliceDecl GhcPs -> R ()
13p_spliceDecl :: SpliceDecl GhcPs -> R ()
14p_spliceDecl = \case
14p_spliceDecl = \case
15− SpliceDecl NoExt splice _explicit -> line $ located splice p_hsSplice
15+ SpliceDecl NoExt splice _explicit -> located splice p_hsSplice
16 XSpliceDecl {} -> notImplemented "XSpliceDecl"
16 XSpliceDecl {} -> notImplemented "XSpliceDecl"
src/Ormolu/Printer/Meat/Declaration/Type.hs+1−1
@@ -21,7 +21,7 @@ p_synDecl
21 -> LHsQTyVars GhcPs -- ^ Type variables
21 -> LHsQTyVars GhcPs -- ^ Type variables
22 -> LHsType GhcPs -- ^ RHS of type declaration
22 -> LHsType GhcPs -- ^ RHS of type declaration
23 -> R ()
23 -> R ()
24−p_synDecl name tvars t = line $ do
24+p_synDecl name tvars t = do
25 txt "type "
25 txt "type "
26 p_rdrName name
26 p_rdrName name
27 let HsQTvs {..} = tvars
27 let HsQTvs {..} = tvars
src/Ormolu/Printer/Meat/Declaration/TypeFamily.hs+3−3
@@ -46,14 +46,14 @@ p_famDecl style FamilyDecl {..} = do
46 when (isJust rsig && isJust fdInjectivityAnn) breakpoint
46 when (isJust rsig && isJust fdInjectivityAnn) breakpoint
47 forM_ fdInjectivityAnn (located' p_injectivityAnn)
47 forM_ fdInjectivityAnn (located' p_injectivityAnn)
48 case mmeqs of
48 case mmeqs of
49− Nothing -> newline
49+ Nothing -> return ()
50 Just meqs -> do
50 Just meqs -> do
51 txt " where"
51 txt " where"
52 case meqs of
52 case meqs of
53− Nothing -> txt " .." >> newline
53+ Nothing -> txt " .."
54 Just eqs -> do
54 Just eqs -> do
55 newline
55 newline
56− forM_ eqs (located' (line . inci . p_tyFamInstEqn))
56+ sep newline (located' (inci . p_tyFamInstEqn)) eqs
57p_famDecl _ (XFamilyDecl NoExt) = notImplemented "XFamilyDecl"
57p_famDecl _ (XFamilyDecl NoExt) = notImplemented "XFamilyDecl"
58
58
59p_familyResultSigL
59p_familyResultSigL
src/Ormolu/Printer/Meat/Declaration/Value.hs+10−10
@@ -54,10 +54,7 @@ data Placement
54 -- of indentation
54 -- of indentation
55
55
56p_valDecl :: HsBindLR GhcPs GhcPs -> R ()
56p_valDecl :: HsBindLR GhcPs GhcPs -> R ()
57−p_valDecl = line . p_valDecl'
57+p_valDecl = \case
58−
59−p_valDecl' :: HsBindLR GhcPs GhcPs -> R ()
60−p_valDecl' = \case
61 FunBind NoExt funId funMatches _ _ -> p_funBind funId funMatches
58 FunBind NoExt funId funMatches _ _ -> p_funBind funId funMatches
62 PatBind NoExt pat grhss _ -> p_match PatternBind False NoSrcStrict [pat] grhss
59 PatBind NoExt pat grhss _ -> p_match PatternBind False NoSrcStrict [pat] grhss
63 VarBind {} -> notImplemented "VarBinds" -- introduced by the type checker
60 VarBind {} -> notImplemented "VarBinds" -- introduced by the type checker
@@ -412,8 +409,8 @@ p_hsLocalBinds = \case
412 (srcSpanStart . getLoc)
409 (srcSpanStart . getLoc)
413 items =
410 items =
414 (Left <$> bagToList bag) ++ (Right <$> lsigs)
411 (Left <$> bagToList bag) ++ (Right <$> lsigs)
415− p_item (Left x) = located x p_valDecl'
412+ p_item (Left x) = located x p_valDecl
416− p_item (Right x) = located x p_sigDecl'
413+ p_item (Right x) = located x p_sigDecl
417 sitcc $ sep newline (sitcc . p_item) (sortOn ssStart items)
414 sitcc $ sep newline (sitcc . p_item) (sortOn ssStart items)
418 HsValBinds NoExt _ -> notImplemented "HsValBinds"
415 HsValBinds NoExt _ -> notImplemented "HsValBinds"
419 HsIPBinds NoExt _ -> notImplemented "HsIPBinds"
416 HsIPBinds NoExt _ -> notImplemented "HsIPBinds"
@@ -546,7 +543,9 @@ p_hsExpr = \case
546 HsDo NoExt ctx es -> do
543 HsDo NoExt ctx es -> do
547 let doBody header = do
544 let doBody header = do
548 txt header
545 txt header
546+ if length (unLoc es) <= 1
547+ then breakpoint
549− newline
548+ else newline
550 inci $ located es (sep newline (located' (sitcc . p_stmt)))
549 inci $ located es (sep newline (located' (sitcc . p_stmt)))
551 compBody = brackets $ located es $ \xs -> do
550 compBody = brackets $ located es $ \xs -> do
552 let p_parBody = sitcc . sep
551 let p_parBody = sitcc . sep
@@ -862,9 +861,10 @@ p_hsBracket = \case
862 txt name
861 txt name
863 txt "|"
862 txt "|"
864 breakpoint'
863 breakpoint'
864+ inci $ do
865− body
865+ body
866− breakpoint'
866+ breakpoint'
867− txt "|]"
867+ txt "|]"
868
868
869----------------------------------------------------------------------------
869----------------------------------------------------------------------------
870-- Helpers
870-- Helpers
src/Ormolu/Printer/Meat/Module.hs+1
@@ -54,6 +54,7 @@ p_hsModule exts (L moduleSpan HsModule {..}) = do
54 forM_ (sortImports hsmodImports) (located' p_hsmodImport)
54 forM_ (sortImports hsmodImports) (located' p_hsmodImport)
55 when (hasImports && hasDecls) newline
55 when (hasImports && hasDecls) newline
56 p_hsDecls Free hsmodDecls
56 p_hsDecls Free hsmodDecls
57+ when hasDecls newline
57 trailingComments <- hasMoreComments
58 trailingComments <- hasMoreComments
58 when (trailingComments && hasModuleHeader) newline
59 when (trailingComments && hasModuleHeader) newline
59 spitRemainingComments
60 spitRemainingComments