mirror of
https://github.com/google/ormolu.git
synced 2024-11-27 13:13:23 +03:00
Fix extra layer of parentheses around operator sections
This commit is contained in:
parent
1e6f4cdc95
commit
e00bd3e72a
@ -9,3 +9,5 @@ baz =
|
|||||||
( *
|
( *
|
||||||
3 ^ 5
|
3 ^ 5
|
||||||
)
|
)
|
||||||
|
|
||||||
|
quux = (,) <$> foo <$> bar
|
||||||
|
@ -5,3 +5,5 @@ baz =
|
|||||||
+ )
|
+ )
|
||||||
( *
|
( *
|
||||||
3 ^ 5)
|
3 ^ 5)
|
||||||
|
|
||||||
|
quux = (,) <$> foo <$> bar
|
||||||
|
@ -56,7 +56,7 @@ p_rdrName l@(L spn _) = located l $ \x -> do
|
|||||||
if AnnOpenP `elem` ids
|
if AnnOpenP `elem` ids
|
||||||
then parens
|
then parens
|
||||||
else id
|
else id
|
||||||
(m, isUnit) =
|
(m, avoidParens) =
|
||||||
case x of
|
case x of
|
||||||
Unqual occName ->
|
Unqual occName ->
|
||||||
(atom occName, False)
|
(atom occName, False)
|
||||||
@ -68,8 +68,8 @@ p_rdrName l@(L spn _) = located l $ \x -> do
|
|||||||
-- NOTE I'm not sure this "stable string" is stable enough, but
|
-- NOTE I'm not sure this "stable string" is stable enough, but
|
||||||
-- it looks like this is the most robust way to tell if we're
|
-- it looks like this is the most robust way to tell if we're
|
||||||
-- looking at exactly this piece of built-in syntax.
|
-- looking at exactly this piece of built-in syntax.
|
||||||
(atom name, nameStableString name == "$ghc-prim$GHC.Tuple$()")
|
(atom name, nameStableString name `elem` avoidParensStableNames)
|
||||||
if isUnit
|
if avoidParens
|
||||||
then m
|
then m
|
||||||
else parensWrapper (backticksWrapper m)
|
else parensWrapper (backticksWrapper m)
|
||||||
|
|
||||||
@ -83,3 +83,13 @@ p_ieWildcard :: IEWildcard -> R ()
|
|||||||
p_ieWildcard = \case
|
p_ieWildcard = \case
|
||||||
NoIEWildcard -> return ()
|
NoIEWildcard -> return ()
|
||||||
IEWildcard n -> parens (atom n)
|
IEWildcard n -> parens (atom n)
|
||||||
|
|
||||||
|
avoidParensStableNames :: [String]
|
||||||
|
avoidParensStableNames =
|
||||||
|
[ "$ghc-prim$GHC.Tuple$()"
|
||||||
|
, "$ghc-prim$GHC.Tuple$(,)"
|
||||||
|
, "$ghc-prim$GHC.Tuple$(,,)"
|
||||||
|
, "$ghc-prim$GHC.Tuple$(,,,)"
|
||||||
|
, "$ghc-prim$GHC.Tuple$(,,,,)"
|
||||||
|
, "$ghc-prim$GHC.Tuple$(,,,,,)"
|
||||||
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user