on master help sign in
Fix rendering of arrow notation with multiline expressions
commit9b7b6eb2391ee9a8a0ea87c46be74d447d9df99a authorMark Karpov <markkarpov92@gmail.com> dateFri 10 Apr 2020, 12:33 (7 years ago) parentea2d80e
13 files changed+99−61
CHANGELOG.md+3 data/examples/declaration/value/function/arrow/multiline-case-out.hs+8 data/examples/declaration/value/function/arrow/multiline-case.hs+7 data/examples/declaration/value/function/arrow/proc-applications-out.hs+6−5 data/examples/declaration/value/function/arrow/proc-do-complex-out.hs+17−13 data/examples/declaration/value/function/arrow/proc-do-simple1-out.hs+3−2 data/examples/declaration/value/function/arrow/proc-do-simple2-out.hs+9−7 data/examples/declaration/value/function/arrow/proc-forms1-out.hs+8−6 data/examples/declaration/value/function/arrow/proc-forms2-out.hs+6−4 data/examples/declaration/value/function/arrow/proc-ifs-out.hs+6−4 data/examples/declaration/value/function/arrow/proc-parentheses-out.hs+5−4 data/examples/declaration/value/function/arrow/recursive-procs-out.hs+14−10 src/Ormolu/Printer/Meat/Declaration/Value.hs+7−6
CHANGELOG.md+3
@@ -16,6 +16,9 @@
1616 now put on its own line. [Issue
1717 509](https://github.com/tweag/ormolu/issues/509).
1818
19+* Fixed the bug pertaining to rendering of arrow notation with multiline
20+ expressions. [Issue 513](https://github.com/tweag/ormolu/issues/513).
21+
1922* Implemented support for the new language extension `ImportQualifiedPost`.
2023
2124* Implemented support for the new language extension
data/examples/declaration/value/function/arrow/multiline-case-out.hsnew file+8
@@ -0,0 +1,8 @@
1+{-# LANGUAGE Arrows #-}
2+
3+f = proc x -> do
4+ x <-
5+ case x of X -> x
6+ -<
7+ y
8+ a -< b
data/examples/declaration/value/function/arrow/multiline-case.hsnew file+7
@@ -0,0 +1,7 @@
1+{-# LANGUAGE Arrows #-}
2+
3+f = proc x -> do
4+ x
5+ <- case x of X -> x
6+ -< y
7+ a -< b
data/examples/declaration/value/function/arrow/proc-applications-out.hs+6−5
@@ -9,10 +9,11 @@ bar f x =
99 w
1010 )
1111 ->
12− f -< -- The value
13− ( x, -- Foo
14− w, -- Bar
15− z -- Baz
16− )
12+ f -- The value
13+ -<
14+ ( x, -- Foo
15+ w, -- Bar
16+ z -- Baz
17+ )
1718
1819baz x = proc a -> a -<< x
data/examples/declaration/value/function/arrow/proc-do-complex-out.hs+17−13
@@ -19,10 +19,11 @@ foo
1919 )
2020 ( b,
2121 d
22− ) -<
23− ( b + 1, -- Funnel into arrow
24− d * b
2522 )
23+ -<
24+ ( b + 1, -- Funnel into arrow
25+ d * b
26+ )
2627 if x `mod` y == 0 -- Basic condition
2728 then case e of -- Only left case is relevant
2829 Left
@@ -32,9 +33,10 @@ foo
3233 let v =
3334 u -- Actually never used
3435 ^ 2
35− in ( returnA -<
36− -- Just do the calculation
37− (x + y * z)
36+ in ( returnA
37+ -<
38+ -- Just do the calculation
39+ (x + y * z)
3840 )
3941 else do
4042 let u = x -- Let bindings bind expressions, not commands
@@ -42,8 +44,9 @@ foo
4244 i <- case u of
4345 0 -> (g . h -< u)
4446 n ->
45− ( ( h . g -<
46− y -- First actual use of y
47+ ( ( h . g
48+ -<
49+ y -- First actual use of y
4750 )
4851 )
4952 returnA -< ()
@@ -51,8 +54,9 @@ foo
5154 if i > 0
5255 then ma -< ()
5356 else returnA -< ()
54− returnA -<
55− ( i
56− + x
57− * y -- Just do the calculation
58− )
57+ returnA
58+ -<
59+ ( i
60+ + x
61+ * y -- Just do the calculation
62+ )
data/examples/declaration/value/function/arrow/proc-do-simple1-out.hs+3−2
@@ -13,5 +13,6 @@ barbaz f g = proc (a, b) -> do
1313
1414bazbar f = proc a -> do
1515 a <-
16− f -<
17− a
16+ f
17+ -<
18+ a
data/examples/declaration/value/function/arrow/proc-do-simple2-out.hs+9−7
@@ -11,10 +11,12 @@ bazbaz f g h = proc (a, b, c) -> do
1111 z <-
1212 h
1313 x
14− y -<
15− ( a,
16− b,
17− c
18− )
19− returnA -<
20− (x, y, z)
14+ y
15+ -<
16+ ( a,
17+ b,
18+ c
19+ )
20+ returnA
21+ -<
22+ (x, y, z)
data/examples/declaration/value/function/arrow/proc-forms1-out.hs+8−6
@@ -7,13 +7,15 @@ foo1 f g h x =
77 (|
88 test
99 ( h f
10− . h g -<
11− y x
12− . y z
10+ . h g
11+ -<
12+ y x
13+ . y z
1314 )
1415 ( h g
15− . h f -<
16− y z
17− . y x
16+ . h f
17+ -<
18+ y z
19+ . y x
1820 )
1921 |)
data/examples/declaration/value/function/arrow/proc-forms2-out.hs+6−4
@@ -12,9 +12,11 @@ bar2 f g h x =
1212
1313bar3 f g h x =
1414 proc (y, z) ->
15− ( (h f . h g) -<
16− (y x) . y z
15+ ( (h f . h g)
16+ -<
17+ (y x) . y z
1718 ) |||
18− ( (h g . h f) -<
19− y z . (y x)
19+ ( (h g . h f)
20+ -<
21+ y z . (y x)
2022 )
data/examples/declaration/value/function/arrow/proc-ifs-out.hs+6−4
@@ -6,8 +6,10 @@ bar f g = proc a ->
66 if f a
77 then
88 f
9− . g -<
10− a
9+ . g
10+ -<
11+ a
1112 else
12− g -<
13− b
13+ g
14+ -<
15+ b
data/examples/declaration/value/function/arrow/proc-parentheses-out.hs+5−4
@@ -6,13 +6,14 @@ bar f g = proc a ->
66 ( ( (f)
77 ( g
88 )
9− ) -<
10− ( ( ( ( ( ( g
11− a
9+ )
10+ -<
11+ ( ( ( ( ( ( g
12+ a
13+ )
1214 )
1315 )
1416 )
1517 )
1618 )
17− )
1819 )
data/examples/declaration/value/function/arrow/recursive-procs-out.hs+14−10
@@ -3,17 +3,21 @@
33foo f g = proc (x, y) -> do
44 rec a <- f y -< x
55 b <-
6− g x -<
7− y
8− bar -<
9− ( a,
10− b
11− )
6+ g x
7+ -<
8+ y
9+ bar
10+ -<
11+ ( a,
12+ b
13+ )
1214 rec p <-
1315 f
14− p -<
15− a
16+ p
17+ -<
18+ a
1619 rec q <-
1720 g
18− q -<
19− b
21+ q
22+ -<
23+ b
src/Ormolu/Printer/Meat/Declaration/Value.hs+7−6
@@ -310,12 +310,13 @@ p_hsCmd :: HsCmd GhcPs -> R ()
310310p_hsCmd = \case
311311 HsCmdArrApp NoExtField body input arrType _ -> do
312312 located body p_hsExpr
313− space
314− case arrType of
315− HsFirstOrderApp -> txt "-<"
316− HsHigherOrderApp -> txt "-<<"
317− placeHanging (exprPlacement (unLoc input)) $
318− located input p_hsExpr
313+ breakpoint
314+ inci $ do
315+ case arrType of
316+ HsFirstOrderApp -> txt "-<"
317+ HsHigherOrderApp -> txt "-<<"
318+ placeHanging (exprPlacement (unLoc input)) $
319+ located input p_hsExpr
319320 HsCmdArrForm NoExtField form Prefix _ cmds -> banana $ sitcc $ do
320321 located form p_hsExpr
321322 unless (null cmds) $ do