From f94400b4860df45fcd72420401393f98abc38445 Mon Sep 17 00:00:00 2001 From: mrkkrp Date: Fri, 16 Aug 2019 22:24:11 +0200 Subject: [PATCH] =?UTF-8?q?Indent=20=E2=80=98then=E2=80=99=20and=20?= =?UTF-8?q?=E2=80=98else=E2=80=99=20clauses=20one=20level=20further?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This arguably improves readability especially when if-then-else is placed inside of a ‘do’-block. --- .../value/function/block-arguments-out.hs | 4 ++-- .../value/function/case-multi-line-out.hs | 4 ++-- .../declaration/value/function/do-out.hs | 4 ++-- .../value/function/if-multi-line-out.hs | 18 +++++++++--------- .../value/function/lambda-multi-line-out.hs | 4 ++-- src/Ormolu/Printer/Meat/Declaration/Value.hs | 17 +++++++++-------- 6 files changed, 26 insertions(+), 25 deletions(-) diff --git a/data/examples/declaration/value/function/block-arguments-out.hs b/data/examples/declaration/value/function/block-arguments-out.hs index 61686ab..1a29c1e 100644 --- a/data/examples/declaration/value/function/block-arguments-out.hs +++ b/data/examples/declaration/value/function/block-arguments-out.hs @@ -20,8 +20,8 @@ f5 = f6 = foo if bar - then baz - else not baz + then baz + else not baz f7 = foo \x -> y diff --git a/data/examples/declaration/value/function/case-multi-line-out.hs b/data/examples/declaration/value/function/case-multi-line-out.hs index a6e1aee..c502952 100644 --- a/data/examples/declaration/value/function/case-multi-line-out.hs +++ b/data/examples/declaration/value/function/case-multi-line-out.hs @@ -8,8 +8,8 @@ bar x = case x of 5 -> if x > 5 - then 10 - else 12 + then 10 + else 12 _ -> 12 baz :: Int -> Int diff --git a/data/examples/declaration/value/function/do-out.hs b/data/examples/declaration/value/function/do-out.hs index 9ec4791..de7f87c 100644 --- a/data/examples/declaration/value/function/do-out.hs +++ b/data/examples/declaration/value/function/do-out.hs @@ -28,8 +28,8 @@ quux = something $ do 2 -> 20 bar if something - then x - else y + then x + else y baz foo = do diff --git a/data/examples/declaration/value/function/if-multi-line-out.hs b/data/examples/declaration/value/function/if-multi-line-out.hs index d04f8e6..8693f5b 100644 --- a/data/examples/declaration/value/function/if-multi-line-out.hs +++ b/data/examples/declaration/value/function/if-multi-line-out.hs @@ -1,16 +1,16 @@ foo :: Int -> Int foo x = if x > 5 - then 10 - else 12 + then 10 + else 12 bar :: Int -> Int bar x = if x > 5 - then - foo x - + 100 - else - case x of - 1 -> 10 - _ -> 20 + then + foo x + + 100 + else + case x of + 1 -> 10 + _ -> 20 diff --git a/data/examples/declaration/value/function/lambda-multi-line-out.hs b/data/examples/declaration/value/function/lambda-multi-line-out.hs index 815c71b..a151d5a 100644 --- a/data/examples/declaration/value/function/lambda-multi-line-out.hs +++ b/data/examples/declaration/value/function/lambda-multi-line-out.hs @@ -5,8 +5,8 @@ foo x = \y -> bar :: Int -> Int -> Int bar x = \y -> if x > y - then 10 - else 12 + then 10 + else 12 tricky0 = flip all (zip ws gs) $ \(wt, gt) -> diff --git a/src/Ormolu/Printer/Meat/Declaration/Value.hs b/src/Ormolu/Printer/Meat/Declaration/Value.hs index 6f03d24..ad9d0dd 100644 --- a/src/Ormolu/Printer/Meat/Declaration/Value.hs +++ b/src/Ormolu/Printer/Meat/Declaration/Value.hs @@ -538,15 +538,16 @@ p_hsExpr = \case txt "if " located if' p_hsExpr breakpoint - txt "then" - located then' $ \x -> do + inci $ do + txt "then" + located then' $ \x -> do + breakpoint + inci (p_hsExpr x) breakpoint - inci (p_hsExpr x) - breakpoint - txt "else" - located else' $ \x -> do - breakpoint - inci (p_hsExpr x) + txt "else" + located else' $ \x -> do + breakpoint + inci (p_hsExpr x) HsMultiIf NoExt guards -> do txt "if" breakpoint