on master help sign in
Hang expressions in if-then-else
8cb86d3Utku Demir
data/examples/declaration/value/function/if-multi-line-out.hs+11−4
@@ -10,7 +10,14 @@ bar x =
10 then
10 then
11 foo x
11 foo x
12 + 100
12 + 100
13− else
14− case x of
13+ else case x of
15− 1 -> 10
14+ 1 -> 10
16− _ -> 20
15+ _ -> 20
16+
17+baz :: Int -> Bar
18+baz x =
19+ if x > 5
20+ then \case
21+ Foo -> bar
22+ else do
23+ undefined
data/examples/declaration/value/function/if-multi-line.hs+10
@@ -10,3 +10,13 @@ bar x =
10 else case x of
10 else case x of
11 1 -> 10
11 1 -> 10
12 _ -> 20
12 _ -> 20
13+
14+baz :: Int -> Bar
15+baz x =
16+ if x > 5
17+ then
18+ \case
19+ Foo -> bar
20+ else
21+ do
22+ undefined
src/Ormolu/Printer/Meat/Declaration/Value.hs+4−6
@@ -540,14 +540,12 @@ p_hsExpr = \case
540 breakpoint
540 breakpoint
541 inci $ do
541 inci $ do
542 txt "then"
542 txt "then"
543− located then' $ \x -> do
543+ located then' $ \x ->
544− breakpoint
544+ placeHanging (exprPlacement x) (p_hsExpr x)
545− inci (p_hsExpr x)
546 breakpoint
545 breakpoint
547 txt "else"
546 txt "else"
548− located else' $ \x -> do
547+ located else' $ \x ->
549− breakpoint
548+ placeHanging (exprPlacement x) (p_hsExpr x)
550− inci (p_hsExpr x)
551 HsMultiIf NoExt guards -> do
549 HsMultiIf NoExt guards -> do
552 txt "if"
550 txt "if"
553 breakpoint
551 breakpoint