Skip to content

Commit 60d92aa

Browse files
authored
Avoid adding redundant brackets around lambdas (#1646)
1 parent c41acee commit 60d92aa

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/GHC/Util/HsExpr.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ niceLambdaR parent = go
243243
-- e.g., parent = `f \x -> g 3 x`; e = `g 3`.
244244
-- Brackets should be placed around `e` to produce `f (g 3)` instead of `f g 3`.
245245
addBrackets = case parent of
246-
Just p -> isApp p && not (isVar e)
246+
Just p -> isApp p && not (isVar e) && not (isLambda e)
247247
Nothing -> False
248248
e' = if addBrackets then mkHsPar e else e
249249
tpl = if addBrackets then "(a)" else "a"

src/Hint/Lambda.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ f = g \x -> h 3 x -- (h 3)
4343
f = g (\x -> h 3 x) -- h 3
4444
f = g \x -> (`h` 3) x -- (`h` 3)
4545
f = g \x -> h x -- h
46+
f = ($ 42) \_ -> pure ()
4647
f = foo (flip op x) -- (`op` x)
4748
f = foo (flip op x) -- @Message Use section
4849
f = foo (flip x y) -- (`x` y)

0 commit comments

Comments
 (0)