From 3d74f2fb53c1af024254b7d28f9d2a14176604fe Mon Sep 17 00:00:00 2001 From: mrkkrp Date: Sun, 7 Jul 2019 14:08:41 +0200 Subject: [PATCH] =?UTF-8?q?Shift=20=E2=80=98in=E2=80=99=20in=20=E2=80=98le?= =?UTF-8?q?t=E2=80=99=20to=20the=20right=20to=20allow=20placing=20it=20in?= =?UTF-8?q?=20do=20blocks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It is a bit uncommon to format it like this, but this way it can be placed without changes in do blocks as well. I think it's the right way go about that bug. --- data/examples/declaration/value/function/do-out.hs | 5 +++++ data/examples/declaration/value/function/do.hs | 5 +++++ .../declaration/value/function/let-multi-line-out.hs | 6 +++--- src/Ormolu/Printer/Meat/Declaration/Value.hs | 2 +- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/data/examples/declaration/value/function/do-out.hs b/data/examples/declaration/value/function/do-out.hs index 1a9ac17..1275a19 100644 --- a/data/examples/declaration/value/function/do-out.hs +++ b/data/examples/declaration/value/function/do-out.hs @@ -47,3 +47,8 @@ foo = do print x y <- c print y + +trickyLet = do + foo + let x = 5 + in bar x diff --git a/data/examples/declaration/value/function/do.hs b/data/examples/declaration/value/function/do.hs index 591d2c3..31666ac 100644 --- a/data/examples/declaration/value/function/do.hs +++ b/data/examples/declaration/value/function/do.hs @@ -46,3 +46,8 @@ foo = do y <- c print y + +trickyLet = do + foo + let x = 5 + in bar x diff --git a/data/examples/declaration/value/function/let-multi-line-out.hs b/data/examples/declaration/value/function/let-multi-line-out.hs index 86e6d9e..36cd74c 100644 --- a/data/examples/declaration/value/function/let-multi-line-out.hs +++ b/data/examples/declaration/value/function/let-multi-line-out.hs @@ -2,11 +2,11 @@ foo :: Int -> Int foo x = let z = y y = x - in z + 100 + in z + 100 bar :: Int -> Int bar x = let z = y y = x - in z + - 100 + in z + + 100 diff --git a/src/Ormolu/Printer/Meat/Declaration/Value.hs b/src/Ormolu/Printer/Meat/Declaration/Value.hs index 94e8b86..f3fbbd5 100644 --- a/src/Ormolu/Printer/Meat/Declaration/Value.hs +++ b/src/Ormolu/Printer/Meat/Declaration/Value.hs @@ -459,7 +459,7 @@ p_hsExpr = \case HsLet NoExt localBinds e -> do txt "let " sitcc (located localBinds p_hsLocalBinds) - breakpoint + vlayout space (newline >> space) txt "in " sitcc (located e p_hsExpr) HsDo NoExt ctx es -> do