From 118558738b6e333b58c33f94df6b3e99d689537f Mon Sep 17 00:00:00 2001 From: Utku Demir Date: Fri, 16 Aug 2019 12:24:34 +1200 Subject: [PATCH] Hang after block arguments --- .../value/function/block-arguments-out.hs | 24 +++++++++++++++++++ .../value/function/block-arguments.hs | 18 ++++++++++++++ src/Ormolu/Printer/Meat/Declaration/Value.hs | 5 ++-- 3 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 data/examples/declaration/value/function/block-arguments-out.hs create mode 100644 data/examples/declaration/value/function/block-arguments.hs diff --git a/data/examples/declaration/value/function/block-arguments-out.hs b/data/examples/declaration/value/function/block-arguments-out.hs new file mode 100644 index 0000000..78eaf9e --- /dev/null +++ b/data/examples/declaration/value/function/block-arguments-out.hs @@ -0,0 +1,24 @@ +f1 = foo do bar + +f2 = + foo do + bar + +f3 = + foo case True of + True -> bar + False -> baz + +f4 = foo let a = 3 in b + +f5 = + foo + let a = 3 + b = a + in b + +f6 = + foo + if bar + then baz + else not baz diff --git a/data/examples/declaration/value/function/block-arguments.hs b/data/examples/declaration/value/function/block-arguments.hs new file mode 100644 index 0000000..9ace93d --- /dev/null +++ b/data/examples/declaration/value/function/block-arguments.hs @@ -0,0 +1,18 @@ +f1 = foo do bar + +f2 = foo do + bar + +f3 = foo case True of + True -> bar + False -> baz + +f4 = foo let a = 3 in b + +f5 = foo let a = 3 + b = a + in b + +f6 = foo if bar + then baz + else not baz diff --git a/src/Ormolu/Printer/Meat/Declaration/Value.hs b/src/Ormolu/Printer/Meat/Declaration/Value.hs index 8e606ab..5ba5914 100644 --- a/src/Ormolu/Printer/Meat/Declaration/Value.hs +++ b/src/Ormolu/Printer/Meat/Declaration/Value.hs @@ -470,8 +470,9 @@ p_hsExpr = \case inci (p_matchGroup LambdaCase mgroup) HsApp NoExt f x -> sitcc $ do located f p_hsExpr - breakpoint - inci (located x p_hsExpr) + -- Second argument can be a `do` or `case` block with `-XBlockArguments`. + placeHanging (exprPlacement (unLoc x)) $ + located x p_hsExpr HsAppType a e -> do located e p_hsExpr breakpoint