on master help sign in
Only force braces on hsLocalBinds on a single-line layout
commit721ba7e3674bd69d829c0d69723b410b6dafd0eb authorUtku Demir <me@utdemir.com> dateTue 27 Aug 2019, 19:00 (7 years ago) parente5b99e8
3 files changed+27−1
data/examples/declaration/value/function/where-nested-out.hs+12 data/examples/declaration/value/function/where-nested.hs+13 src/Ormolu/Printer/Meat/Declaration/Value.hs+2−1
data/examples/declaration/value/function/where-nested-out.hsnew file+12
@@ -0,0 +1,12 @@
1+foo = bar
2+ where
3+ f1 = f1
4+ where
5+ f1 = 3
6+ f2 = f2
7+ where
8+ f2 = 3
9+
10+foo2 = bar
11+ where
12+ f1 = f1 where { f1 = 3; f1' = 4 }; f2 = f2 where f2 = 3; f2' = 4
data/examples/declaration/value/function/where-nested.hsnew file+13
@@ -0,0 +1,13 @@
1+foo = bar
2+ where
3+ f1 = f1
4+ where
5+ f1 = 3
6+ f2 = f2
7+ where
8+ f2 = 3
9+
10+foo2 = bar
11+ where
12+ { f1 = f1 where { f1 = 3; f1' = 4 }; f2 = f2 where { f2 = 3; f2' = 4 } }
13+
src/Ormolu/Printer/Meat/Declaration/Value.hs+2−1
@@ -420,8 +420,9 @@ p_hsLocalBinds = \case
420420 -- NOTE When in a single-line layout, there is a chance that the inner
421421 -- elements will also contain semicolons and they will confuse the
422422 -- parser. so we request braces around every element except the last.
423+ br <- vlayout (return useBraces) (return id)
423424 sitcc $ sepSemi
424− (\(m, i) -> (if m then useBraces else id) $ p_item i)
425+ (\(m, i) -> (if m then br else id) $ p_item i)
425426 (markInit $ sortOn ssStart items)
426427 HsValBinds NoExt _ -> notImplemented "HsValBinds"
427428 HsIPBinds NoExt (IPBinds NoExt xs) ->