on master help sign in
Make case expressions hanging
46d175cmrkkrp
data/examples/declaration/value/function/case-multi-line-out.hs+14−18
@@ -1,25 +1,21 @@
1foo :: Int -> Int
1foo :: Int -> Int
2−foo x =
3− case x of
2+foo x = case x of
4− 5 -> 10
3+ 5 -> 10
5− _ -> 12
4+ _ -> 12
6
5
7bar :: Int -> Int
6bar :: Int -> Int
8−bar x =
9− case x of
7+bar x = case x of
10− 5 ->
8+ 5 ->
11− if x > 5
9+ if x > 5
12− then 10
10+ then 10
13− else 12
11+ else 12
14− _ -> 12
12+ _ -> 12
15
13
16baz :: Int -> Int
14baz :: Int -> Int
17−baz x =
18− case x of
15+baz x = case x of
19− 5 -> 10
16+ 5 -> 10
20− _ -> 12
17+ _ -> 12
21
18
22quux :: Int -> Int
19quux :: Int -> Int
23−quux x =
24− case x of
20+quux x = case x of
25− x -> x
21+ x -> x
src/Ormolu/Printer/Meat/Declaration/Value.hs+2−1
@@ -279,7 +279,7 @@ p_hsExpr = \case
279 located e p_hsExpr
279 located e p_hsExpr
280 txt " of"
280 txt " of"
281 breakpoint
281 breakpoint
282− inci (p_matchGroup Case mgroup)
282+ p_matchGroup Case mgroup
283 HsIf NoExt _ if' then' else' -> do
283 HsIf NoExt _ if' then' else' -> do
284 txt "if "
284 txt "if "
285 located if' p_hsExpr
285 located if' p_hsExpr
@@ -447,6 +447,7 @@ isPrefixBlock _ = False
447isPrefixBlockExpr :: HsExpr GhcPs -> Bool
447isPrefixBlockExpr :: HsExpr GhcPs -> Bool
448isPrefixBlockExpr = \case
448isPrefixBlockExpr = \case
449 HsLam NoExt _ -> True
449 HsLam NoExt _ -> True
450+ HsCase NoExt _ _ -> True
450 HsDo NoExt _ _ -> True
451 HsDo NoExt _ _ -> True
451 HsLamCase NoExt _ -> True
452 HsLamCase NoExt _ -> True
452 _ -> False
453 _ -> False