Preserve operators promotion (single quote)

Fixes #222
This commit is contained in:
gabriele.lana 2019-07-20 13:32:01 +02:00 committed by Mark Karpov
parent 0065a9baf6
commit 8d52d87d72
2 changed files with 11 additions and 5 deletions

View File

@ -1,3 +1,3 @@
fun1 :: Def ('[Ref s (Stored Uint32), IBool] T.:-> IBool)
fun1 :: Def ('[Ref s (Stored Uint32), IBool] 'T.:-> IBool)
fun2 :: Def ('[Ref s (Stored Uint32), IBool] :-> IBool)
fun2 :: Def ('[Ref s (Stored Uint32), IBool] ':-> IBool)

View File

@ -49,7 +49,6 @@ p_ieWrappedName = \case
p_rdrName :: Located RdrName -> R ()
p_rdrName l@(L spn _) = located l $ \x -> do
ids <- getAnns spn
-- NOTE Right now we're mainly interested in backticks and parentheses.
let backticksWrapper =
if AnnBackquote `elem` ids
then backticks
@ -58,6 +57,12 @@ p_rdrName l@(L spn _) = located l $ \x -> do
if AnnOpenP `elem` ids
then parens
else id
singleQuoteWrapper =
if AnnSimpleQuote `elem` ids
then \y -> do
txt "'"
y
else id
(m, avoidParens) =
case x of
Unqual occName ->
@ -80,9 +85,10 @@ p_rdrName l@(L spn _) = located l $ \x -> do
( atom name
, "$ghc-prim$GHC.Tuple$" `isPrefixOf` nameStableString name
)
m' = backticksWrapper (singleQuoteWrapper m)
if avoidParens
then m
else parensWrapper (backticksWrapper m)
then m'
else parensWrapper m'
p_qualName :: ModuleName -> OccName -> R ()
p_qualName mname occName = do