on master help sign in
Fix TH quoting of operators
0cf6d65Utku Demir
data/examples/declaration/splice/quotes-out.hs+4
@@ -2,10 +2,14 @@ foo = ''R
2
2
3bar = 'foo
3bar = 'foo
4
4
5+bar' = 'foo_bar
6+
5baz = ''(:#)
7baz = ''(:#)
6
8
7baz' = ''(Foo.Bar.:#)
9baz' = ''(Foo.Bar.:#)
8
10
11+equals = ''(==)
12+
9unit = ''()
13unit = ''()
10
14
11list = ''[]
15list = ''[]
data/examples/declaration/splice/quotes.hs+4
@@ -2,10 +2,14 @@ foo = ''R
2
2
3bar = 'foo
3bar = 'foo
4
4
5+bar' = 'foo_bar
6+
5baz = ''(:#)
7baz = ''(:#)
6
8
7baz' = ''(Foo.Bar.:#)
9baz' = ''(Foo.Bar.:#)
8
10
11+equals = ''(==)
12+
9unit = ''()
13unit = ''()
10
14
11list = ''[]
15list = ''[]
src/Ormolu/Printer/Meat/Declaration/Value.hs+5−3
@@ -15,7 +15,7 @@ import Bag (bagToList)
15import BasicTypes
15import BasicTypes
16import Control.Monad
16import Control.Monad
17import Data.Bool (bool)
17import Data.Bool (bool)
18−import Data.Char (isPunctuation)
18+import Data.Char (isPunctuation, isSymbol)
19import Data.Data hiding (Infix, Prefix)
19import Data.Data hiding (Infix, Prefix)
20import Data.List (intersperse, sortOn)
20import Data.List (intersperse, sortOn)
21import Data.Text (Text)
21import Data.Text (Text)
@@ -843,8 +843,10 @@ p_hsBracket = \case
843 -- turn makes it impossible to detect if there are parentheses around
843 -- turn makes it impossible to detect if there are parentheses around
844 -- it, etc. So we have to add parentheses manually assuming they are
844 -- it, etc. So we have to add parentheses manually assuming they are
845 -- necessary for all operators.
845 -- necessary for all operators.
846+ let isOperator = all
847+ (\i -> isPunctuation i || isSymbol i)
846− let isOperator = any isPunctuation (showOutputable (rdrNameOcc name))
848+ (showOutputable (rdrNameOcc name))
847− && not (doesNotNeedExtraParens name)
849+ && not (doesNotNeedExtraParens name)
848 wrapper = if isOperator then parens else id
850 wrapper = if isOperator then parens else id
849 wrapper $ p_rdrName (noLoc name)
851 wrapper $ p_rdrName (noLoc name)
850 TExpBr NoExt expr -> do
852 TExpBr NoExt expr -> do