Vladislav Zavialov pushed to branch wip/int-index/epa-parens at Glasgow Haskell Compiler / GHC

Commits:

13 changed files:

Changes:

  • compiler/GHC/Hs/Dump.hs
    ... ... @@ -221,7 +221,6 @@ showAstData bs ba a0 = blankLine $$ showAstData' a0
    221 221
                  NoBlankEpAnnotations -> parens (case ap of
    
    222 222
                                           (AnnParens       o c) -> text "AnnParens"       $$ vcat [showAstData' o, showAstData' c]
    
    223 223
                                           (AnnParensHash   o c) -> text "AnnParensHash"   $$ vcat [showAstData' o, showAstData' c]
    
    224
    -                                      (AnnParensSquare o c) -> text "AnnParensSquare" $$ vcat [showAstData' o, showAstData' c]
    
    225 224
                                           )
    
    226 225
     
    
    227 226
                 annClassDecl :: AnnClassDecl -> SDoc
    

  • compiler/GHC/Hs/Expr.hs
    ... ... @@ -263,7 +263,7 @@ type instance XPar GhcPs = (EpToken "(", EpToken ")")
    263 263
     type instance XPar           GhcRn = NoExtField
    
    264 264
     type instance XPar           GhcTc = NoExtField
    
    265 265
     
    
    266
    -type instance XExplicitTuple GhcPs = (EpaLocation, EpaLocation)
    
    266
    +type instance XExplicitTuple GhcPs = AnnParen
    
    267 267
     type instance XExplicitTuple GhcRn = NoExtField
    
    268 268
     type instance XExplicitTuple GhcTc = NoExtField
    
    269 269
     
    
    ... ... @@ -556,14 +556,13 @@ mkHsVarWithUserRdr rdr n = HsVar noExtField $
    556 556
     
    
    557 557
     data AnnExplicitSum
    
    558 558
       = AnnExplicitSum {
    
    559
    -      aesOpen       :: EpaLocation,
    
    559
    +      aesParens     :: AnnParen,
    
    560 560
           aesBarsBefore :: [EpToken "|"],
    
    561
    -      aesBarsAfter  :: [EpToken "|"],
    
    562
    -      aesClose      :: EpaLocation
    
    561
    +      aesBarsAfter  :: [EpToken "|"]
    
    563 562
           } deriving Data
    
    564 563
     
    
    565 564
     instance NoAnn AnnExplicitSum where
    
    566
    -  noAnn = AnnExplicitSum noAnn noAnn noAnn noAnn
    
    565
    +  noAnn = AnnExplicitSum noAnn noAnn noAnn
    
    567 566
     
    
    568 567
     data AnnFieldLabel
    
    569 568
       = AnnFieldLabel {
    

  • compiler/GHC/Hs/Pat.hs
    ... ... @@ -113,7 +113,7 @@ type instance XListPat GhcRn = NoExtField
    113 113
     type instance XListPat GhcTc = Type
    
    114 114
       -- List element type, for use in hsPatType.
    
    115 115
     
    
    116
    -type instance XTuplePat GhcPs = (EpaLocation, EpaLocation)
    
    116
    +type instance XTuplePat GhcPs = AnnParen
    
    117 117
     type instance XTuplePat GhcRn = NoExtField
    
    118 118
     type instance XTuplePat GhcTc = [Type]
    
    119 119
     
    
    ... ... @@ -260,13 +260,13 @@ discarded inside tcMatchPats, where we know if visible pattern retained or erase
    260 260
     -- API Annotations types
    
    261 261
     
    
    262 262
     data EpAnnSumPat = EpAnnSumPat
    
    263
    -      { sumPatParens      :: (EpaLocation, EpaLocation)
    
    263
    +      { sumPatParens      :: AnnParen
    
    264 264
           , sumPatVbarsBefore :: [EpToken "|"]
    
    265 265
           , sumPatVbarsAfter  :: [EpToken "|"]
    
    266 266
           } deriving Data
    
    267 267
     
    
    268 268
     instance NoAnn EpAnnSumPat where
    
    269
    -  noAnn = EpAnnSumPat (noAnn, noAnn) [] []
    
    269
    +  noAnn = EpAnnSumPat noAnn [] []
    
    270 270
     
    
    271 271
     -- ---------------------------------------------------------------------
    
    272 272
     
    

  • compiler/GHC/Hs/Type.hs
    ... ... @@ -430,7 +430,7 @@ type instance XQualTy (GhcPass _) = NoExtField
    430 430
     type instance XTyVar           (GhcPass _) = EpToken "'"
    
    431 431
     type instance XAppTy           (GhcPass _) = NoExtField
    
    432 432
     type instance XFunTy           (GhcPass _) = NoExtField
    
    433
    -type instance XListTy          (GhcPass _) = AnnParen
    
    433
    +type instance XListTy          (GhcPass _) = (EpToken "[", EpToken "]")
    
    434 434
     type instance XTupleTy         (GhcPass _) = AnnParen
    
    435 435
     type instance XSumTy           (GhcPass _) = AnnParen
    
    436 436
     type instance XOpTy            (GhcPass _) = NoExtField
    
    ... ... @@ -455,7 +455,7 @@ type instance XExplicitListTy GhcPs = (EpToken "'", EpToken "[", EpToken "]")
    455 455
     type instance XExplicitListTy  GhcRn = NoExtField
    
    456 456
     type instance XExplicitListTy  GhcTc = Kind
    
    457 457
     
    
    458
    -type instance XExplicitTupleTy GhcPs = (EpToken "'", EpToken "(", EpToken ")")
    
    458
    +type instance XExplicitTupleTy GhcPs = (EpToken "'", AnnParen)
    
    459 459
     type instance XExplicitTupleTy GhcRn = NoExtField
    
    460 460
     type instance XExplicitTupleTy GhcTc = [Kind]
    
    461 461
     
    

  • compiler/GHC/Parser.y
    ... ... @@ -2370,14 +2370,14 @@ atype :: { LHsType GhcPs }
    2370 2370
             | '(' ktype ')'               {% amsA' (sLL $1 $> $ HsParTy (epTok $1, epTok $3) $2) }
    
    2371 2371
                                           -- see Note [Promotion] for the followings
    
    2372 2372
             | SIMPLEQUOTE '(' ')'         {% do { requireLTPuns PEP_QuoteDisambiguation $1 $>
    
    2373
    -                                            ; amsA' (sLL $1 $> $ HsExplicitTupleTy (epTok $1,epTok $2,epTok $3) IsPromoted []) }}
    
    2373
    +                                            ; amsA' (sLL $1 $> $ HsExplicitTupleTy (epTok $1, AnnParens (epTok $2) (epTok $3)) IsPromoted []) }}
    
    2374 2374
             | SIMPLEQUOTE gen_qcon {% amsA' (sLL $1 $> $ HsTyVar (epTok $1) IsPromoted $2) }
    
    2375 2375
             | SIMPLEQUOTE sysdcon_nolist {% do { requireLTPuns PEP_QuoteDisambiguation $1 (reLoc $>)
    
    2376 2376
                                                ; amsA' (sLL $1 $> $ HsTyVar (epTok $1) IsPromoted (L (getLoc $2) $ nameRdrName (dataConName (unLoc $2)))) }}
    
    2377 2377
             | SIMPLEQUOTE  '(' ktype ',' comma_types1 ')'
    
    2378 2378
                                  {% do { requireLTPuns PEP_QuoteDisambiguation $1 $>
    
    2379 2379
                                        ; h <- addTrailingCommaA $3 (epTok $4)
    
    2380
    -                                   ; amsA' (sLL $1 $> $ HsExplicitTupleTy (epTok $1,epTok $2,epTok $6) IsPromoted (h : $5)) }}
    
    2380
    +                                   ; amsA' (sLL $1 $> $ HsExplicitTupleTy (epTok $1, AnnParens (epTok $2) (epTok $6)) IsPromoted (h : $5)) }}
    
    2381 2381
             | '[' ']'               {% withCombinedComments $1 $> (mkListSyntaxTy0 (epTok $1) (epTok $2)) }
    
    2382 2382
             | SIMPLEQUOTE  '[' comma_types0 ']'     {% do { requireLTPuns PEP_QuoteDisambiguation $1 $>
    
    2383 2383
                                                           ; amsA' (sLL $1 $> $ HsExplicitListTy (epTok $1, epTok $2, epTok $4) IsPromoted $3) }}
    
    ... ... @@ -3185,7 +3185,7 @@ aexp2 :: { ECP }
    3185 3185
             | '(' tup_exprs ')'             { ECP $
    
    3186 3186
                                                $2 >>= \ $2 ->
    
    3187 3187
                                                mkSumOrTuplePV (noAnnSrcSpan $ comb2 $1 $>) Boxed $2
    
    3188
    -                                                (glR $1,glR $3)}
    
    3188
    +                                                (AnnParens (epTok $1) (epTok $3))}
    
    3189 3189
     
    
    3190 3190
             | '(' orpats(exp2) ')'          {% do
    
    3191 3191
                                                   { pat <- hintOrPats (sL1a $2 (OrPat NoExtField (unLoc $2)))
    
    ... ... @@ -3201,11 +3201,11 @@ aexp2 :: { ECP }
    3201 3201
             | '(#' texp '#)'                { ECP $
    
    3202 3202
                                                unECP $2 >>= \ $2 ->
    
    3203 3203
                                                mkSumOrTuplePV (noAnnSrcSpan $ comb2 $1 $>) Unboxed (Tuple [Right $2])
    
    3204
    -                                                 (glR $1,glR $3) }
    
    3204
    +                                                 (AnnParensHash (epTok $1) (epTok $3)) }
    
    3205 3205
             | '(#' tup_exprs '#)'           { ECP $
    
    3206 3206
                                                $2 >>= \ $2 ->
    
    3207 3207
                                                mkSumOrTuplePV (noAnnSrcSpan $ comb2 $1 $>) Unboxed $2
    
    3208
    -                                                (glR $1,glR $3) }
    
    3208
    +                                                (AnnParensHash (epTok $1) (epTok $3)) }
    
    3209 3209
     
    
    3210 3210
             | '[' list ']'      { ECP $ $2 (comb2 $1 $>) (glR $1,glR $3) }
    
    3211 3211
             | '_'               { ECP $ mkHsWildCardPV (getLoc $1) }
    

  • compiler/GHC/Parser/Annotation.hs
    ... ... @@ -552,12 +552,11 @@ data AnnListBrackets
    552 552
     -- Annotations for parenthesised elements, such as tuples, lists
    
    553 553
     -- ---------------------------------------------------------------------
    
    554 554
     
    
    555
    --- | exact print annotation for an item having surrounding "brackets", such as
    
    556
    --- tuples or lists
    
    555
    +-- | exact print annotation for an item having parentheses, with or without
    
    556
    +-- the hash symbol, e.g. tuples, unboxed tuples, unboxed sums
    
    557 557
     data AnnParen
    
    558 558
       = AnnParens       (EpToken "(")  (EpToken ")")  -- ^ '(', ')'
    
    559 559
       | AnnParensHash   (EpToken "(#") (EpToken "#)") -- ^ '(#', '#)'
    
    560
    -  | AnnParensSquare (EpToken "[")  (EpToken "]")  -- ^ '[', ']'
    
    561 560
       deriving Data
    
    562 561
     
    
    563 562
     -- ---------------------------------------------------------------------
    
    ... ... @@ -1219,7 +1218,6 @@ instance (Outputable e)
    1219 1218
     instance Outputable AnnParen where
    
    1220 1219
       ppr (AnnParens       o c) = text "AnnParens" <+> ppr o <+> ppr c
    
    1221 1220
       ppr (AnnParensHash   o c) = text "AnnParensHash" <+> ppr o <+> ppr c
    
    1222
    -  ppr (AnnParensSquare o c) = text "AnnParensSquare" <+> ppr o <+> ppr c
    
    1223 1221
     
    
    1224 1222
     instance Outputable AnnListItem where
    
    1225 1223
       ppr (AnnListItem ts) = text "AnnListItem" <+> ppr ts
    

  • compiler/GHC/Parser/PostProcess.hs
    ... ... @@ -1223,17 +1223,11 @@ checkContext orig_t@(L (EpAnn l _ cs) _orig_t) =
    1223 1223
       -- With NoListTuplePuns, contexts are parsed as data constructors, which causes failure
    
    1224 1224
       -- downstream.
    
    1225 1225
       -- This converts them just like when they are parsed as types in the punned case.
    
    1226
    -  check (oparens,cparens,cs) (L _l (HsExplicitTupleTy (q,o,c) _ ts))
    
    1227
    -    = punsAllowed >>= \case
    
    1228
    -      True -> unprocessed
    
    1229
    -      False -> do
    
    1230
    -        let
    
    1231
    -          (op, cp) = case q of
    
    1232
    -            EpTok ql -> ([EpTok ql], [c])
    
    1233
    -            _        -> ([o], [c])
    
    1234
    -        mkCTuple (oparens ++ op, cp ++ cparens, cs) ts
    
    1226
    +  check (oparens,cparens,cs) (L _l (HsExplicitTupleTy (_, AnnParens o c) NotPromoted ts))
    
    1227
    +    = mkCTuple (oparens ++ [o], c : cparens, cs) ts
    
    1228
    +
    
    1235 1229
       check (opi,cpi,csi) (L _lp1 (HsParTy (o,c) ty))
    
    1236
    -                                             -- to be sure HsParTy doesn't get into the way
    
    1230
    +                                             -- to be sure HsParTy doesn't get in the way
    
    1237 1231
         = check (o:opi, c:cpi, csi) ty
    
    1238 1232
     
    
    1239 1233
       -- No need for anns, returning original
    
    ... ... @@ -1264,11 +1258,10 @@ checkContextExpr orig_expr@(L (EpAnn l _ cs) _) =
    1264 1258
       where
    
    1265 1259
         check :: ([EpToken "("],[EpToken ")"],EpAnnComments)
    
    1266 1260
             -> LHsExpr GhcPs -> PV (LocatedC [LHsExpr GhcPs])
    
    1267
    -    check (oparens,cparens,cs) (L _ (ExplicitTuple (ap_open, ap_close) tup_args boxity))
    
    1261
    +    check (oparens,cparens,cs) (L _ (ExplicitTuple (AnnParens open_tok close_tok) tup_args Boxed))
    
    1268 1262
                  -- Neither unboxed tuples (#e1,e2#) nor tuple sections (e1,,e2,) can be a context
    
    1269
    -      | isBoxed boxity
    
    1270
    -      , Just es <- tupArgsPresent_maybe tup_args
    
    1271
    -      = mkCTuple (oparens ++ [EpTok ap_open], EpTok ap_close : cparens, cs) es
    
    1263
    +      | Just es <- tupArgsPresent_maybe tup_args
    
    1264
    +      = mkCTuple (oparens ++ [open_tok], close_tok : cparens, cs) es
    
    1272 1265
         check (opi, cpi, csi) (L _ (HsPar (open_tok, close_tok) expr))
    
    1273 1266
           = check (opi ++ [open_tok], close_tok : cpi, csi) expr
    
    1274 1267
         check (oparens,cparens,cs) (L _ (HsVar _ (L (EpAnn _ (NameAnnOnly (NameParens open closed) []) _) name)))
    
    ... ... @@ -1841,7 +1834,7 @@ class (b ~ (Body b) GhcPs, AnnoBody b) => DisambECP b where
    1841 1834
       mkHsBangPatPV :: SrcSpan -> LocatedA b -> EpToken "!" -> PV (LocatedA b)
    
    1842 1835
       -- | Disambiguate tuple sections and unboxed sums
    
    1843 1836
       mkSumOrTuplePV
    
    1844
    -    :: SrcSpanAnnA -> Boxity -> SumOrTuple b -> (EpaLocation, EpaLocation) -> PV (LocatedA b)
    
    1837
    +    :: SrcSpanAnnA -> Boxity -> SumOrTuple b -> AnnParen -> PV (LocatedA b)
    
    1845 1838
       -- | Disambiguate "type t" (embedded type)
    
    1846 1839
       mkHsEmbTyPV :: SrcSpan -> EpToken "type" -> LHsType GhcPs -> PV (LocatedA b)
    
    1847 1840
       -- | Validate infixexp LHS to reject unwanted {-# SCC ... #-} pragmas
    
    ... ... @@ -3663,7 +3656,7 @@ hintBangPat span e = do
    3663 3656
           addError $ mkPlainErrorMsgEnvelope span $ PsErrIllegalBangPattern e
    
    3664 3657
     
    
    3665 3658
     mkSumOrTupleExpr :: SrcSpanAnnA -> Boxity -> SumOrTuple (HsExpr GhcPs)
    
    3666
    -                 -> (EpaLocation, EpaLocation)
    
    3659
    +                 -> AnnParen
    
    3667 3660
                      -> PV (LHsExpr GhcPs)
    
    3668 3661
     
    
    3669 3662
     -- Tuple
    
    ... ... @@ -3678,15 +3671,15 @@ mkSumOrTupleExpr l@(EpAnn anc an csIn) boxity (Tuple es) anns = do
    3678 3671
     -- Sum
    
    3679 3672
     -- mkSumOrTupleExpr l Unboxed (Sum alt arity e) =
    
    3680 3673
     --     return $ L l (ExplicitSum noExtField alt arity e)
    
    3681
    -mkSumOrTupleExpr l@(EpAnn anc anIn csIn) Unboxed (Sum alt arity e barsp barsa) (o, c) = do
    
    3682
    -    let an = AnnExplicitSum o barsp barsa c
    
    3674
    +mkSumOrTupleExpr l@(EpAnn anc anIn csIn) Unboxed (Sum alt arity e barsp barsa) anns = do
    
    3675
    +    let an = AnnExplicitSum anns barsp barsa
    
    3683 3676
         !cs <- getCommentsFor (locA l)
    
    3684 3677
         return $ L (EpAnn anc anIn (csIn Semi.<> cs)) (ExplicitSum an alt arity e)
    
    3685 3678
     mkSumOrTupleExpr l Boxed a@Sum{} _ =
    
    3686 3679
         addFatalError $ mkPlainErrorMsgEnvelope (locA l) $ PsErrUnsupportedBoxedSumExpr a
    
    3687 3680
     
    
    3688 3681
     mkSumOrTuplePat
    
    3689
    -  :: SrcSpanAnnA -> Boxity -> SumOrTuple (PatBuilder GhcPs) -> (EpaLocation, EpaLocation)
    
    3682
    +  :: SrcSpanAnnA -> Boxity -> SumOrTuple (PatBuilder GhcPs) -> AnnParen
    
    3690 3683
       -> PV (LocatedA (PatBuilder GhcPs))
    
    3691 3684
     
    
    3692 3685
     -- Tuple
    
    ... ... @@ -3842,7 +3835,7 @@ mkTupleSyntaxTy parOpen args parClose =
    3842 3835
           HsExplicitTupleTy annsKeyword NotPromoted args
    
    3843 3836
     
    
    3844 3837
         annParen = AnnParens parOpen parClose
    
    3845
    -    annsKeyword = (NoEpTok, parOpen, parClose)
    
    3838
    +    annsKeyword = (NoEpTok, annParen)
    
    3846 3839
     
    
    3847 3840
     -- | Decide whether to parse tuple con syntax @(,)@ in a type as a
    
    3848 3841
     -- type or data constructor, based on the extension @ListTuplePuns@.
    
    ... ... @@ -3894,7 +3887,7 @@ mkListSyntaxTy1 brkOpen t brkClose =
    3894 3887
           HsExplicitListTy annsKeyword NotPromoted [t]
    
    3895 3888
     
    
    3896 3889
         annsKeyword = (NoEpTok, brkOpen, brkClose)
    
    3897
    -    annParen = AnnParensSquare brkOpen brkClose
    
    3890
    +    annParen = (brkOpen, brkClose)
    
    3898 3891
     
    
    3899 3892
     parseError :: HsExpr GhcPs
    
    3900 3893
     parseError = HsHole HoleError

  • testsuite/tests/ghc-api/T25121_status.stdout
    ... ... @@ -18,8 +18,8 @@ X(ExplicitList) mismatch
    18 18
       >>> AnnList ()
    
    19 19
       <<< ((EpToken "'"),(EpToken "["),(EpToken "]"))
    
    20 20
     X(ExplicitTuple) mismatch
    
    21
    -  >>> ((EpaLocation' [GenLocated (EpaLocation' NoComments) EpaComment]),(EpaLocation' [GenLocated (EpaLocation' NoComments) EpaComment]))
    
    22
    -  <<< ((EpToken "'"),(EpToken "("),(EpToken ")"))
    
    21
    +  >>> AnnParen
    
    22
    +  <<< ((EpToken "'"),AnnParen)
    
    23 23
     X(Hole) mismatch
    
    24 24
       >>> HoleKind
    
    25 25
       <<< EpToken "_"
    

  • testsuite/tests/parser/should_compile/DumpParsedAst.stderr
    ... ... @@ -265,7 +265,7 @@
    265 265
                 (EpaComments
    
    266 266
                  []))
    
    267 267
                (HsListTy
    
    268
    -            (AnnParensSquare
    
    268
    +            ((,)
    
    269 269
                  (EpTok
    
    270 270
                   (EpaSpan { DumpParsedAst.hs:9:16 }))
    
    271 271
                  (EpTok
    
    ... ... @@ -647,7 +647,7 @@
    647 647
                   (EpaComments
    
    648 648
                    []))
    
    649 649
                  (HsListTy
    
    650
    -              (AnnParensSquare
    
    650
    +              ((,)
    
    651 651
                    (EpTok
    
    652 652
                     (EpaSpan { DumpParsedAst.hs:10:27 }))
    
    653 653
                    (EpTok
    

  • testsuite/tests/parser/should_compile/DumpRenamedAst.stderr
    ... ... @@ -596,7 +596,7 @@
    596 596
                     (EpaComments
    
    597 597
                      []))
    
    598 598
                    (HsListTy
    
    599
    -                (AnnParensSquare
    
    599
    +                ((,)
    
    600 600
                      (EpTok
    
    601 601
                       (EpaSpan { DumpRenamedAst.hs:12:27 }))
    
    602 602
                      (EpTok
    
    ... ... @@ -701,7 +701,7 @@
    701 701
                   (EpaComments
    
    702 702
                    []))
    
    703 703
                  (HsListTy
    
    704
    -              (AnnParensSquare
    
    704
    +              ((,)
    
    705 705
                    (EpTok
    
    706 706
                     (EpaSpan { DumpRenamedAst.hs:11:16 }))
    
    707 707
                    (EpTok
    
    ... ... @@ -1896,7 +1896,7 @@
    1896 1896
                    (EpaComments
    
    1897 1897
                     []))
    
    1898 1898
                   (HsListTy
    
    1899
    -               (AnnParensSquare
    
    1899
    +               ((,)
    
    1900 1900
                     (EpTok
    
    1901 1901
                      (EpaSpan { DumpRenamedAst.hs:31:12 }))
    
    1902 1902
                     (EpTok
    
    ... ... @@ -1961,7 +1961,7 @@
    1961 1961
                      (EpaComments
    
    1962 1962
                       []))
    
    1963 1963
                     (HsListTy
    
    1964
    -                 (AnnParensSquare
    
    1964
    +                 ((,)
    
    1965 1965
                       (EpTok
    
    1966 1966
                        (EpaSpan { DumpRenamedAst.hs:32:10 }))
    
    1967 1967
                       (EpTok
    

  • testsuite/tests/parser/should_compile/KindSigs.stderr
    ... ... @@ -728,7 +728,7 @@
    728 728
             (EpaComments
    
    729 729
              []))
    
    730 730
            (HsListTy
    
    731
    -        (AnnParensSquare
    
    731
    +        ((,)
    
    732 732
              (EpTok
    
    733 733
               (EpaSpan { KindSigs.hs:19:12 }))
    
    734 734
              (EpTok
    
    ... ... @@ -1417,13 +1417,14 @@
    1417 1417
             (EpaComments
    
    1418 1418
              []))
    
    1419 1419
            (HsExplicitTupleTy
    
    1420
    -        ((,,)
    
    1420
    +        ((,)
    
    1421 1421
              (EpTok
    
    1422 1422
               (EpaSpan { KindSigs.hs:28:16 }))
    
    1423
    -         (EpTok
    
    1424
    -          (EpaSpan { KindSigs.hs:28:17 }))
    
    1425
    -         (EpTok
    
    1426
    -          (EpaSpan { KindSigs.hs:28:44 })))
    
    1423
    +         (AnnParens
    
    1424
    +          (EpTok
    
    1425
    +           (EpaSpan { KindSigs.hs:28:17 }))
    
    1426
    +          (EpTok
    
    1427
    +           (EpaSpan { KindSigs.hs:28:44 }))))
    
    1427 1428
             (IsPromoted)
    
    1428 1429
             [(L
    
    1429 1430
               (EpAnn
    
    ... ... @@ -1501,7 +1502,7 @@
    1501 1502
                  (EpaComments
    
    1502 1503
                   []))
    
    1503 1504
                 (HsListTy
    
    1504
    -             (AnnParensSquare
    
    1505
    +             ((,)
    
    1505 1506
                   (EpTok
    
    1506 1507
                    (EpaSpan { KindSigs.hs:28:34 }))
    
    1507 1508
                   (EpTok
    

  • testsuite/tests/parser/should_compile/T20452.stderr
    ... ... @@ -453,7 +453,7 @@
    453 453
                  (EpaComments
    
    454 454
                   []))
    
    455 455
                 (HsListTy
    
    456
    -             (AnnParensSquare
    
    456
    +             ((,)
    
    457 457
                   (EpTok
    
    458 458
                    (EpaSpan { T20452.hs:8:57 }))
    
    459 459
                   (EpTok
    
    ... ... @@ -699,7 +699,7 @@
    699 699
                  (EpaComments
    
    700 700
                   []))
    
    701 701
                 (HsListTy
    
    702
    -             (AnnParensSquare
    
    702
    +             ((,)
    
    703 703
                   (EpTok
    
    704 704
                    (EpaSpan { T20452.hs:9:57 }))
    
    705 705
                   (EpTok
    

  • utils/check-exact/ExactPrint.hs
    ... ... @@ -857,9 +857,6 @@ markParenO (AnnParens o c) = do
    857 857
     markParenO (AnnParensHash o c) = do
    
    858 858
       o' <- markEpToken o
    
    859 859
       return (AnnParensHash o' c)
    
    860
    -markParenO (AnnParensSquare o c) = do
    
    861
    -  o' <- markEpToken o
    
    862
    -  return (AnnParensSquare o' c)
    
    863 860
     
    
    864 861
     markParenC :: (Monad m, Monoid w) => AnnParen -> EP w m AnnParen
    
    865 862
     markParenC (AnnParens o c) = do
    
    ... ... @@ -868,9 +865,6 @@ markParenC (AnnParens o c) = do
    868 865
     markParenC (AnnParensHash o c) = do
    
    869 866
       c' <- markEpToken c
    
    870 867
       return (AnnParensHash o c')
    
    871
    -markParenC (AnnParensSquare o c) = do
    
    872
    -  c' <- markEpToken c
    
    873
    -  return (AnnParensSquare o c')
    
    874 868
     
    
    875 869
     -- ---------------------------------------------------------------------
    
    876 870
     -- Bare bones Optics
    
    ... ... @@ -1014,15 +1008,14 @@ lsnd k parent = fmap (\new -> (fst parent, new))
    1014 1008
     -- -------------------------------------
    
    1015 1009
     -- data AnnExplicitSum
    
    1016 1010
     --   = AnnExplicitSum {
    
    1017
    ---       aesOpen       :: EpaLocation,
    
    1011
    +--       aesParens     :: AnnParen,
    
    1018 1012
     --       aesBarsBefore :: [EpToken "|"],
    
    1019
    ---       aesBarsAfter  :: [EpToken "|"],
    
    1020
    ---       aesClose      :: EpaLocation
    
    1013
    +--       aesBarsAfter  :: [EpToken "|"]
    
    1021 1014
     --       } deriving Data
    
    1022 1015
     
    
    1023
    -laesOpen :: Lens AnnExplicitSum EpaLocation
    
    1024
    -laesOpen k parent = fmap (\new -> parent { aesOpen = new })
    
    1025
    -                         (k (aesOpen parent))
    
    1016
    +laesParens :: Lens AnnExplicitSum AnnParen
    
    1017
    +laesParens k parent = fmap (\new -> parent { aesParens = new })
    
    1018
    +                           (k (aesParens parent))
    
    1026 1019
     
    
    1027 1020
     laesBarsBefore :: Lens AnnExplicitSum [EpToken "|"]
    
    1028 1021
     laesBarsBefore k parent = fmap (\new -> parent { aesBarsBefore = new })
    
    ... ... @@ -1032,10 +1025,6 @@ laesBarsAfter :: Lens AnnExplicitSum [EpToken "|"]
    1032 1025
     laesBarsAfter k parent = fmap (\new -> parent { aesBarsAfter = new })
    
    1033 1026
                                    (k (aesBarsAfter parent))
    
    1034 1027
     
    
    1035
    -laesClose :: Lens AnnExplicitSum EpaLocation
    
    1036
    -laesClose k parent = fmap (\new -> parent { aesClose = new })
    
    1037
    -                               (k (aesClose parent))
    
    1038
    -
    
    1039 1028
     -- -------------------------------------
    
    1040 1029
     -- data AnnFieldLabel
    
    1041 1030
     --   = AnnFieldLabel {
    
    ... ... @@ -1182,12 +1171,12 @@ lga_sep k parent = fmap (\new -> parent { ga_sep = new })
    1182 1171
     
    
    1183 1172
     -- ---------------------------------------------------------------------
    
    1184 1173
     -- data EpAnnSumPat = EpAnnSumPat
    
    1185
    ---       { sumPatParens      :: (EpaLocation, EpaLocation)
    
    1174
    +--       { sumPatParens      :: AnnParen
    
    1186 1175
     --       , sumPatVbarsBefore :: [EpToken "|"]
    
    1187 1176
     --       , sumPatVbarsAfter  :: [EpToken "|"]
    
    1188 1177
     --       } deriving Data
    
    1189 1178
     
    
    1190
    -lsumPatParens :: Lens EpAnnSumPat (EpaLocation, EpaLocation)
    
    1179
    +lsumPatParens :: Lens EpAnnSumPat AnnParen
    
    1191 1180
     lsumPatParens k parent = fmap (\new -> parent { sumPatParens = new })
    
    1192 1181
                                   (k (sumPatParens parent))
    
    1193 1182
     
    
    ... ... @@ -2929,23 +2918,21 @@ instance ExactPrint (HsExpr GhcPs) where
    2929 2918
         expr' <- markAnnotated expr
    
    2930 2919
         return (SectionR an op' expr')
    
    2931 2920
     
    
    2932
    -  exact (ExplicitTuple (o,c) args b) = do
    
    2933
    -    o0 <- if b == Boxed then printStringAtAA o "("
    
    2934
    -                        else printStringAtAA o "(#"
    
    2921
    +  exact (ExplicitTuple an args b) = do
    
    2922
    +    an0 <- markOpeningParen an
    
    2935 2923
     
    
    2936 2924
         args' <- mapM markAnnotated args
    
    2937 2925
     
    
    2938
    -    c0 <- if b == Boxed then printStringAtAA c ")"
    
    2939
    -                        else printStringAtAA c "#)"
    
    2926
    +    an1 <- markClosingParen an0
    
    2940 2927
         debugM $ "ExplicitTuple done"
    
    2941
    -    return (ExplicitTuple (o0,c0) args' b)
    
    2928
    +    return (ExplicitTuple an1 args' b)
    
    2942 2929
     
    
    2943 2930
       exact (ExplicitSum an alt arity expr) = do
    
    2944
    -    an0 <- markLensFun an laesOpen (\loc -> printStringAtAA loc "(#")
    
    2931
    +    an0 <- markLensFun an laesParens markOpeningParen
    
    2945 2932
         an1 <- markLensFun an0 laesBarsBefore (\locs -> mapM markEpToken locs)
    
    2946 2933
         expr' <- markAnnotated expr
    
    2947 2934
         an2 <- markLensFun an1 laesBarsAfter (\locs -> mapM markEpToken locs)
    
    2948
    -    an3 <- markLensFun an2 laesClose (\loc -> printStringAtAA loc "#)")
    
    2935
    +    an3 <- markLensFun an2 laesParens markClosingParen
    
    2949 2936
         return (ExplicitSum an3 alt arity expr')
    
    2950 2937
     
    
    2951 2938
       exact (HsCase an e alts) = do
    
    ... ... @@ -3954,11 +3941,11 @@ instance ExactPrint (HsType GhcPs) where
    3954 3941
         (mult', ty1') <- markMultAnnOf mult (markAnnotated ty1)
    
    3955 3942
         ty2' <- markAnnotated ty2
    
    3956 3943
         return (HsFunTy an mult' ty1' ty2')
    
    3957
    -  exact (HsListTy an tys) = do
    
    3958
    -    an0 <- markOpeningParen an
    
    3959
    -    tys' <- markAnnotated tys
    
    3960
    -    an1 <- markClosingParen an0
    
    3961
    -    return (HsListTy an1 tys')
    
    3944
    +  exact (HsListTy (o,c) t) = do
    
    3945
    +    o' <- markEpToken o
    
    3946
    +    t' <- markAnnotated t
    
    3947
    +    c' <- markEpToken c
    
    3948
    +    return (HsListTy (o',c') t')
    
    3962 3949
       exact (HsTupleTy an con tys) = do
    
    3963 3950
         an0 <- markOpeningParen an
    
    3964 3951
         tys' <- markAnnotated tys
    
    ... ... @@ -4010,14 +3997,14 @@ instance ExactPrint (HsType GhcPs) where
    4010 3997
         tys' <- markAnnotated tys
    
    4011 3998
         c' <- markEpToken c
    
    4012 3999
         return (HsExplicitListTy (sq',o',c') prom tys')
    
    4013
    -  exact (HsExplicitTupleTy (sq, o, c) prom tys) = do
    
    4000
    +  exact (HsExplicitTupleTy (sq, an) prom tys) = do
    
    4014 4001
         sq' <- if (isPromoted prom)
    
    4015 4002
                   then markEpToken sq
    
    4016 4003
                   else return sq
    
    4017
    -    o' <- markEpToken o
    
    4004
    +    an0 <- markOpeningParen an
    
    4018 4005
         tys' <- markAnnotated tys
    
    4019
    -    c' <- markEpToken c
    
    4020
    -    return (HsExplicitTupleTy (sq', o', c') prom tys')
    
    4006
    +    an1 <- markClosingParen an0
    
    4007
    +    return (HsExplicitTupleTy (sq', an1) prom tys')
    
    4021 4008
       exact (HsTyLit an lit) = do
    
    4022 4009
         lit' <- withPpr lit
    
    4023 4010
         return (HsTyLit an lit')
    
    ... ... @@ -4688,22 +4675,18 @@ instance ExactPrint (Pat GhcPs) where
    4688 4675
         (an', pats') <- markAnnList' an (markAnnotated pats)
    
    4689 4676
         return (ListPat an' pats')
    
    4690 4677
     
    
    4691
    -  exact (TuplePat (o,c) pats boxity) = do
    
    4692
    -    o0 <- case boxity of
    
    4693
    -             Boxed   -> printStringAtAA o "("
    
    4694
    -             Unboxed -> printStringAtAA o "(#"
    
    4678
    +  exact (TuplePat an pats boxity) = do
    
    4679
    +    an0 <- markOpeningParen an
    
    4695 4680
         pats' <- markAnnotated pats
    
    4696
    -    c0 <- case boxity of
    
    4697
    -             Boxed   -> printStringAtAA c ")"
    
    4698
    -             Unboxed -> printStringAtAA c "#)"
    
    4699
    -    return (TuplePat (o0,c0) pats' boxity)
    
    4681
    +    an1 <- markClosingParen an0
    
    4682
    +    return (TuplePat an1 pats' boxity)
    
    4700 4683
     
    
    4701 4684
       exact (SumPat an pat alt arity) = do
    
    4702
    -    an0 <- markLensFun an (lsumPatParens . lfst) (\loc -> printStringAtAA loc "(#")
    
    4685
    +    an0 <- markLensFun an lsumPatParens markOpeningParen
    
    4703 4686
         an1 <- markLensFun an0 lsumPatVbarsBefore (\locs -> mapM markEpToken locs)
    
    4704 4687
         pat' <- markAnnotated pat
    
    4705 4688
         an2 <- markLensFun an1 lsumPatVbarsAfter (\locs -> mapM markEpToken locs)
    
    4706
    -    an3 <- markLensFun an2 (lsumPatParens . lsnd)  (\loc -> printStringAtAA loc "#)")
    
    4689
    +    an3 <- markLensFun an2 lsumPatParens markClosingParen
    
    4707 4690
         return (SumPat an3 pat' alt arity)
    
    4708 4691
     
    
    4709 4692
       exact (OrPat an pats) = do