on master help sign in
Fix TH quoting of operators
commit0cf6d654ebd2bcba5d0a29236fbf47329bd43137 authorUtku Demir <me@utdemir.com> dateWed 14 Aug 2019, 11:24 (7 years ago) parente21e4ef
3 files changed+13−3
data/examples/declaration/splice/quotes-out.hs+4 data/examples/declaration/splice/quotes.hs+4 src/Ormolu/Printer/Meat/Declaration/Value.hs+5−3
data/examples/declaration/splice/quotes-out.hs+4
@@ -2,10 +2,14 @@ foo = ''R
22
33bar = 'foo
44
5+bar' = 'foo_bar
6+
57baz = ''(:#)
68
79baz' = ''(Foo.Bar.:#)
810
11+equals = ''(==)
12+
913unit = ''()
1014
1115list = ''[]
data/examples/declaration/splice/quotes.hs+4
@@ -2,10 +2,14 @@ foo = ''R
22
33bar = 'foo
44
5+bar' = 'foo_bar
6+
57baz = ''(:#)
68
79baz' = ''(Foo.Bar.:#)
810
11+equals = ''(==)
12+
913unit = ''()
1014
1115list = ''[]
src/Ormolu/Printer/Meat/Declaration/Value.hs+5−3
@@ -15,7 +15,7 @@ import Bag (bagToList)
1515import BasicTypes
1616import Control.Monad
1717import Data.Bool (bool)
18−import Data.Char (isPunctuation)
18+import Data.Char (isPunctuation, isSymbol)
1919import Data.Data hiding (Infix, Prefix)
2020import Data.List (intersperse, sortOn)
2121import Data.Text (Text)
@@ -843,8 +843,10 @@ p_hsBracket = \case
843843 -- turn makes it impossible to detect if there are parentheses around
844844 -- it, etc. So we have to add parentheses manually assuming they are
845845 -- necessary for all operators.
846− let isOperator = any isPunctuation (showOutputable (rdrNameOcc name))
847− && not (doesNotNeedExtraParens name)
846+ let isOperator = all
847+ (\i -> isPunctuation i || isSymbol i)
848+ (showOutputable (rdrNameOcc name))
849+ && not (doesNotNeedExtraParens name)
848850 wrapper = if isOperator then parens else id
849851 wrapper $ p_rdrName (noLoc name)
850852 TExpBr NoExt expr -> do