Hang expressions in if-then-else
commit8cb86d3fac66267299a435e509bfce216ed04c6d
authorUtku Demir <me@utdemir.com>
dateMon 19 Aug 2019, 10:42 (7 years ago)
parent9a1f5eb
data/examples/declaration/value/function/if-multi-line-out.hs+11−4
@@ -10,7 +10,14 @@ bar x =
1010 then
1111 foo x
1212 + 100
13− else
14− case x of
15− 1 -> 10
16− _ -> 20
13+ else case x of
14+ 1 -> 10
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 =
1010 else case x of
1111 1 -> 10
1212 _ -> 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
540540 breakpoint
541541 inci $ do
542542 txt "then"
543− located then' $ \x -> do
544− breakpoint
545− inci (p_hsExpr x)
543+ located then' $ \x ->
544+ placeHanging (exprPlacement x) (p_hsExpr x)
546545 breakpoint
547546 txt "else"
548− located else' $ \x -> do
549− breakpoint
550− inci (p_hsExpr x)
547+ located else' $ \x ->
548+ placeHanging (exprPlacement x) (p_hsExpr x)
551549 HsMultiIf NoExt guards -> do
552550 txt "if"
553551 breakpoint