@@ -54,10 +54,7 @@ data Placement
54 -- of indentation
54 -- of indentation
56p_valDecl :: HsBindLR GhcPs GhcPs -> R ()
56p_valDecl :: HsBindLR GhcPs GhcPs -> R ()
57−p_valDecl = line . p_valDecl'
57+p_valDecl = \case
59−p_valDecl' :: HsBindLR GhcPs GhcPs -> R ()
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)
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
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
864 breakpoint'
863 breakpoint'
866− breakpoint'
866+ breakpoint'
867− txt "|]"
867+ txt "|]"
869----------------------------------------------------------------------------
869----------------------------------------------------------------------------
870-- Helpers
870-- Helpers