on master help sign in
Preserve operators promotion (single quote)

Fixes #222

commit8d52d87d7244faad8ad8b4da16ff74209e6d647c authorgabriele.lana <gabriele.lana@gmail.com> dateSat 20 Jul 2019, 13:32 (7 years ago) parent0065a9b
2 files changed+11−5
data/examples/declaration/signature/type/infix-promoted-type-constructor-out.hs+2−2 src/Ormolu/Printer/Meat/Common.hs+9−3
data/examples/declaration/signature/type/infix-promoted-type-constructor-out.hs+2−2
@@ -1,3 +1,3 @@
1−fun1 :: Def ('[Ref s (Stored Uint32), IBool] T.:-> IBool)
1+fun1 :: Def ('[Ref s (Stored Uint32), IBool] 'T.:-> IBool)
22
3−fun2 :: Def ('[Ref s (Stored Uint32), IBool] :-> IBool)
3+fun2 :: Def ('[Ref s (Stored Uint32), IBool] ':-> IBool)
src/Ormolu/Printer/Meat/Common.hs+9−3
@@ -49,7 +49,6 @@ p_ieWrappedName = \case
4949p_rdrName :: Located RdrName -> R ()
5050p_rdrName l@(L spn _) = located l $ \x -> do
5151 ids <- getAnns spn
52− -- NOTE Right now we're mainly interested in backticks and parentheses.
5352 let backticksWrapper =
5453 if AnnBackquote `elem` ids
5554 then backticks
@@ -58,6 +57,12 @@ p_rdrName l@(L spn _) = located l $ \x -> do
5857 if AnnOpenP `elem` ids
5958 then parens
6059 else id
60+ singleQuoteWrapper =
61+ if AnnSimpleQuote `elem` ids
62+ then \y -> do
63+ txt "'"
64+ y
65+ else id
6166 (m, avoidParens) =
6267 case x of
6368 Unqual occName ->
@@ -80,9 +85,10 @@ p_rdrName l@(L spn _) = located l $ \x -> do
8085 ( atom name
8186 , "$ghc-prim$GHC.Tuple$" `isPrefixOf` nameStableString name
8287 )
88+ m' = backticksWrapper (singleQuoteWrapper m)
8389 if avoidParens
84− then m
85− else parensWrapper (backticksWrapper m)
90+ then m'
91+ else parensWrapper m'
8692
8793p_qualName :: ModuleName -> OccName -> R ()
8894p_qualName mname occName = do