Alan Zimmerman pushed to branch wip/az/exactprint-annotation-rationalisation at Glasgow Haskell Compiler / GHC

Commits:

11 changed files:

Changes:

  • compiler/GHC/Hs/Dump.hs
    ... ... @@ -69,6 +69,7 @@ showAstData bs ba a0 = blankLine $$ showAstData' a0
    69 69
                   `extQ` annotationAnnList
    
    70 70
                   `extQ` annotationAnnListWhere
    
    71 71
                   `extQ` annotationAnnListCommas
    
    72
    +              `extQ` annotationAnnListEpaLocation
    
    72 73
                   `extQ` annotationNoEpAnns
    
    73 74
                   `extQ` annotationExprBracket
    
    74 75
                   `extQ` annotationTypedBracket
    
    ... ... @@ -375,6 +376,12 @@ showAstData bs ba a0 = blankLine $$ showAstData' a0
    375 376
                 annotationAnnListCommas :: EpAnn (AnnList [EpToken ","]) -> SDoc
    
    376 377
                 annotationAnnListCommas = annotation' (text "EpAnn (AnnList [EpToken \",\"])")
    
    377 378
     
    
    379
    +            annotationAnnListEpaLocation :: AnnList EpaLocation -> SDoc
    
    380
    +            annotationAnnListEpaLocation anns = case ba of
    
    381
    +             BlankEpAnnotations -> parens (text "blanked:" <+> text "AnnList EpaLocation")
    
    382
    +             NoBlankEpAnnotations -> parens $ text (showConstr (toConstr anns))
    
    383
    +                                               $$ vcat (gmapQ showAstData' anns)
    
    384
    +
    
    378 385
                 annotationNoEpAnns :: EpAnn NoEpAnns -> SDoc
    
    379 386
                 annotationNoEpAnns = annotation' (text "EpAnn NoEpAnns")
    
    380 387
     
    

  • compiler/GHC/Hs/Expr.hs
    ... ... @@ -535,9 +535,6 @@ type instance XPragE (GhcPass _) = NoExtField
    535 535
     
    
    536 536
     type instance XFunRhs  = AnnFunRhs
    
    537 537
     
    
    538
    -type instance Anno [LocatedA ((StmtLR (GhcPass pl) (GhcPass pr) (LocatedA (body (GhcPass pr)))))] = SrcSpanAnnLW
    
    539
    -type instance Anno (StmtLR GhcRn GhcRn (LocatedA (body GhcRn))) = SrcSpanAnnA
    
    540
    -
    
    541 538
     mkHsVar :: forall p. IsPass p => LIdP (GhcPass p) -> HsExpr (GhcPass p)
    
    542 539
     mkHsVar n = HsVar noExtField $
    
    543 540
       case ghcPass @p of
    
    ... ... @@ -2647,8 +2644,8 @@ instance UnXRec p => Outputable (DotFieldOcc p) where
    2647 2644
     
    
    2648 2645
     type instance Anno (HsExpr (GhcPass p)) = SrcSpanAnnA
    
    2649 2646
     type instance Anno [LocatedA (HsExpr (GhcPass p))] = SrcSpanAnnA
    
    2650
    -type instance Anno [LocatedA (StmtLR (GhcPass pl) (GhcPass pr) (LocatedA (HsExpr (GhcPass pr))))] = SrcSpanAnnLW
    
    2651
    -type instance Anno [LocatedA (StmtLR (GhcPass pl) (GhcPass pr) (LocatedA (HsCmd (GhcPass pr))))] = SrcSpanAnnLW
    
    2647
    +type instance Anno [LocatedA (StmtLR (GhcPass pl) (GhcPass pr) (LocatedA (HsExpr (GhcPass pr))))] = SrcSpanAnnA
    
    2648
    +type instance Anno [LocatedA (StmtLR (GhcPass pl) (GhcPass pr) (LocatedA (HsCmd (GhcPass pr))))] = SrcSpanAnnA
    
    2652 2649
     
    
    2653 2650
     type instance Anno (HsCmd (GhcPass p)) = SrcSpanAnnA
    
    2654 2651
     
    
    ... ... @@ -2664,7 +2661,7 @@ type instance Anno (StmtLR (GhcPass pl) (GhcPass pr) (LocatedA (body (GhcPass pr
    2664 2661
     
    
    2665 2662
     type instance Anno (HsUntypedSplice (GhcPass p)) = SrcSpanAnnA
    
    2666 2663
     
    
    2667
    -type instance Anno [LocatedA (StmtLR (GhcPass pl) (GhcPass pr) (LocatedA (body (GhcPass pr))))] = SrcSpanAnnLW
    
    2664
    +type instance Anno [LocatedA (StmtLR (GhcPass pl) (GhcPass pr) (LocatedA (body (GhcPass pr))))] = SrcSpanAnnA
    
    2668 2665
     
    
    2669 2666
     type instance Anno (FieldLabelStrings (GhcPass p)) = EpAnnCO
    
    2670 2667
     type instance Anno FieldLabelString                = SrcSpanAnnN
    

  • compiler/GHC/Hs/Utils.hs
    ... ... @@ -320,8 +320,8 @@ nlParPat p = noLocA (gParPat p)
    320 320
     mkHsIntegral   :: IntegralLit -> HsOverLit GhcPs
    
    321 321
     mkHsFractional :: FractionalLit -> HsOverLit GhcPs
    
    322 322
     mkHsIsString   :: SourceText -> FastString -> HsOverLit GhcPs
    
    323
    -mkHsDo         :: HsDoFlavour -> LocatedLW [ExprLStmt GhcPs] -> HsExpr GhcPs
    
    324
    -mkHsDoAnns     :: HsDoFlavour -> LocatedLW [ExprLStmt GhcPs] -> AnnList EpaLocation -> HsExpr GhcPs
    
    323
    +mkHsDo         :: HsDoFlavour -> LocatedA [ExprLStmt GhcPs] -> HsExpr GhcPs
    
    324
    +mkHsDoAnns     :: HsDoFlavour -> LocatedA [ExprLStmt GhcPs] -> AnnList EpaLocation -> HsExpr GhcPs
    
    325 325
     mkHsComp       :: HsDoFlavour -> [ExprLStmt GhcPs] -> LHsExpr GhcPs
    
    326 326
                    -> HsExpr GhcPs
    
    327 327
     mkHsCompAnns   :: HsDoFlavour -> [ExprLStmt GhcPs] -> LHsExpr GhcPs
    
    ... ... @@ -349,12 +349,12 @@ mkTcBindStmt :: LPat GhcTc -> LocatedA (bodyR GhcTc)
    349 349
     emptyRecStmt     :: (Anno [GenLocated
    
    350 350
                                  (Anno (StmtLR (GhcPass idL) GhcPs bodyR))
    
    351 351
                                  (StmtLR (GhcPass idL) GhcPs bodyR)]
    
    352
    -                        ~ SrcSpanAnnLW)
    
    352
    +                        ~ SrcSpanAnnA)
    
    353 353
                      => StmtLR (GhcPass idL) GhcPs bodyR
    
    354 354
     emptyRecStmtName :: (Anno [GenLocated
    
    355 355
                                  (Anno (StmtLR GhcRn GhcRn bodyR))
    
    356 356
                                  (StmtLR GhcRn GhcRn bodyR)]
    
    357
    -                        ~ SrcSpanAnnLW)
    
    357
    +                        ~ SrcSpanAnnA)
    
    358 358
                      => StmtLR GhcRn GhcRn bodyR
    
    359 359
     emptyRecStmtId   :: Stmt GhcTc (LocatedA (HsCmd GhcTc))
    
    360 360
     
    
    ... ... @@ -362,9 +362,9 @@ mkRecStmt :: forall (idL :: Pass) bodyR.
    362 362
                         (Anno [GenLocated
    
    363 363
                                  (Anno (StmtLR (GhcPass idL) GhcPs bodyR))
    
    364 364
                                  (StmtLR (GhcPass idL) GhcPs bodyR)]
    
    365
    -                        ~ SrcSpanAnnLW)
    
    365
    +                        ~ SrcSpanAnnA)
    
    366 366
                      => AnnList (EpToken "rec")
    
    367
    -                 -> LocatedLW [LStmtLR (GhcPass idL) GhcPs bodyR]
    
    367
    +                 -> LocatedA [LStmtLR (GhcPass idL) GhcPs bodyR]
    
    368 368
                      -> StmtLR (GhcPass idL) GhcPs bodyR
    
    369 369
     mkRecStmt anns stmts  = (emptyRecStmt' anns :: StmtLR (GhcPass idL) GhcPs bodyR)
    
    370 370
                                  { recS_stmts = stmts }
    

  • compiler/GHC/Parser.y
    ... ... @@ -3144,15 +3144,17 @@ aexp :: { ECP }
    3144 3144
                                           return $ ECP $
    
    3145 3145
                                             $2 >>= \ $2 ->
    
    3146 3146
                                             mkHsDoPV (comb2 $1 $2)
    
    3147
    +                                                 (stmtlistAnns $2)
    
    3147 3148
                                                      (fmap mkModuleNameFS (getDO $1))
    
    3148
    -                                                 $2
    
    3149
    +                                                 (stmtlistStmts $2)
    
    3149 3150
                                                      (glR $1)
    
    3150 3151
                                                      (glR $2) }
    
    3151 3152
             | MDO stmtlist             {% hintQualifiedDo $1 >> runPV $2 >>= \ $2 ->
    
    3152 3153
                                            fmap ecpFromExp $
    
    3153 3154
                                            amsA' (L (comb2 $1 $2)
    
    3154
    -                                              (mkMDo (MDoExpr $ fmap mkModuleNameFS (getMDO $1))
    
    3155
    -                                                     $2
    
    3155
    +                                              (mkMDo (stmtlistAnns $2)
    
    3156
    +                                                     (MDoExpr $ fmap mkModuleNameFS (getMDO $1))
    
    3157
    +                                                     (stmtlistStmts $2)
    
    3156 3158
                                                          (glR $1)
    
    3157 3159
                                                          (glR $2))) }
    
    3158 3160
             | 'proc' aexp '->' exp
    
    ... ... @@ -3648,11 +3650,11 @@ apat : aexp {% (checkPattern <=< runPV) (unECP $1) }
    3648 3650
     -----------------------------------------------------------------------------
    
    3649 3651
     -- Statement sequences
    
    3650 3652
     
    
    3651
    -stmtlist :: { forall b. DisambECP b => PV (LocatedLW [LocatedA (Stmt GhcPs (LocatedA b))]) }
    
    3653
    +stmtlist :: { forall b. DisambECP b => PV (LocatedA ((EpToken "{", [EpToken ";"], EpToken "}"), Located [LocatedA (Stmt GhcPs (LocatedA b))])) }
    
    3652 3654
             : '{'           stmts '}'       { $2 >>= \ $2 ->
    
    3653
    -                                          amsr (sLL $1 $> (reverse $ snd $ unLoc $2)) (AnnList (stmtsAnchor $2) (ListBraces (epTok $1) (epTok $3)) (fromOL $ fst $ unLoc $2) noAnn []) }
    
    3654
    -        |     vocurly   stmts close     { $2 >>= \ $2 -> amsr
    
    3655
    -                                          (L (stmtsLoc $2) (reverse $ snd $ unLoc $2)) (AnnList (stmtsAnchor $2) ListNone (fromOL $ fst $ unLoc $2) noAnn []) }
    
    3655
    +                                          amsA' (sLL $1 $> ((epTok $1, fromOL $ fst $ unLoc $2, epTok $3), sL1 $2 $ reverse $ snd $ unLoc $2))}
    
    3656
    +        |     vocurly   stmts close     { $2 >>= \ $2 ->
    
    3657
    +                                          amsA' (L (stmtsLoc $2) ((NoEpTok, fromOL $ fst $ unLoc $2, NoEpTok), sL1 $2 $ reverse $ snd $ unLoc $2))}
    
    3656 3658
     
    
    3657 3659
     --      do { ;; s ; s ; ; s ;; }
    
    3658 3660
     -- The last Stmt should be an expression, but that's hard to enforce
    
    ... ... @@ -3694,7 +3696,8 @@ e_stmt :: { LStmt GhcPs (LHsExpr GhcPs) }
    3694 3696
     stmt  :: { forall b. DisambECP b => PV (LStmt GhcPs (LocatedA b)) }
    
    3695 3697
             : qual                          { $1 }
    
    3696 3698
             | 'rec' stmtlist                {  $2 >>= \ $2 ->
    
    3697
    -                                           amsA' (sLL $1 $> $ mkRecStmt (hsDoAnn (epTok $1) $2) $2) }
    
    3699
    +                                           amsA' (sLL $1 $> $ mkRecStmt (hsDoAnn (epTok $1) (stmtlistAnns $2) $2)
    
    3700
    +                                                                        (stmtlistStmts $2)) }
    
    3698 3701
     
    
    3699 3702
     qual  :: { forall b. DisambECP b => PV (LStmt GhcPs (LocatedA b)) }
    
    3700 3703
         : bindpat '<-' exp                   { unECP $3 >>= \ $3 ->
    
    ... ... @@ -4717,9 +4720,9 @@ commentsPA la@(L l a) = do
    4717 4720
       !cs <- getPriorCommentsFor (getLocA la)
    
    4718 4721
       return (L (addCommentsToEpAnn l cs) a)
    
    4719 4722
     
    
    4720
    -hsDoAnn :: EpToken "rec" -> LocatedAn t b -> AnnList (EpToken "rec")
    
    4721
    -hsDoAnn tok (L ll _)
    
    4722
    -  = AnnList (Just $ spanAsAnchor (locA ll)) ListNone [] tok []
    
    4723
    +hsDoAnn :: EpToken "rec" -> (EpToken "{", [EpToken ";"], EpToken "}") -> LocatedAn t b -> AnnList (EpToken "rec")
    
    4724
    +hsDoAnn rec (ob, semis, cb) (L ll _)
    
    4725
    +  = AnnList (Just $ spanAsAnchor (locA ll)) (ListBraces ob cb) semis rec []
    
    4723 4726
     
    
    4724 4727
     listAsAnchorM :: [LocatedAn t a] -> Maybe EpaLocation
    
    4725 4728
     listAsAnchorM [] = Nothing
    
    ... ... @@ -4745,6 +4748,17 @@ epExplicitBraces !t1 !t2 = EpExplicitBraces (epTok t1) (epTok t2)
    4745 4748
     
    
    4746 4749
     -- -------------------------------------
    
    4747 4750
     
    
    4751
    +stmtlistStmts :: LocatedA (a, Located [LocatedA (Stmt GhcPs (LocatedA b))])
    
    4752
    +              -> LocatedA [LocatedA (Stmt GhcPs (LocatedA b))]
    
    4753
    +stmtlistStmts (L la (_,L l stmts))
    
    4754
    +  = L ((noAnnSrcSpan l) {comments = comments la}) stmts
    
    4755
    +
    
    4756
    +stmtlistAnns :: LocatedA ((EpToken "{", [EpToken ";"], EpToken "}"), a)
    
    4757
    +             -> (EpToken "{", [EpToken ";"], EpToken "}")
    
    4758
    +stmtlistAnns (L _ (an,_)) = an
    
    4759
    +
    
    4760
    +-- -------------------------------------
    
    4761
    +
    
    4748 4762
     addTrailingCommaFBind :: MonadP m => Fbind b -> EpToken "," -> m (Fbind b)
    
    4749 4763
     addTrailingCommaFBind (Left b)  l = fmap Left  (addTrailingCommaA b l)
    
    4750 4764
     addTrailingCommaFBind (Right b) l = fmap Right (addTrailingCommaA b l)
    

  • compiler/GHC/Parser/PostProcess.hs
    ... ... @@ -436,9 +436,9 @@ mkRoleAnnotDecl loc tycon roles anns
    436 436
                 addFatalError $ mkPlainErrorMsgEnvelope loc_role $
    
    437 437
                   (PsErrIllegalRoleName role nearby)
    
    438 438
     
    
    439
    -mkMDo :: HsDoFlavour -> LocatedLW [ExprLStmt GhcPs] -> EpaLocation -> EpaLocation -> HsExpr GhcPs
    
    440
    -mkMDo ctxt stmts tok loc
    
    441
    -  = mkHsDoAnns ctxt stmts (AnnList (Just loc) ListNone [] tok [])
    
    439
    +mkMDo :: (EpToken "{", [EpToken ";"], EpToken "}") -> HsDoFlavour -> LocatedA [ExprLStmt GhcPs] -> EpaLocation -> EpaLocation -> HsExpr GhcPs
    
    440
    +mkMDo (ob, semis, cb) ctxt stmts tok loc
    
    441
    +  = mkHsDoAnns ctxt stmts (AnnList (Just loc) (ListBraces ob cb) semis tok [])
    
    442 442
     
    
    443 443
     -- | Converts a list of 'LHsTyVarBndr's annotated with their 'Specificity' to
    
    444 444
     -- binders without annotations. Only accepts specified variables, and errors if
    
    ... ... @@ -1733,7 +1733,7 @@ type AnnoBody b
    1733 1733
         , Anno (Match GhcPs (LocatedA (Body b GhcPs))) ~ SrcSpanAnnA
    
    1734 1734
         , Anno (StmtLR GhcPs GhcPs (LocatedA (Body (Body b GhcPs) GhcPs))) ~ SrcSpanAnnA
    
    1735 1735
         , Anno [LocatedA (StmtLR GhcPs GhcPs
    
    1736
    -                       (LocatedA (Body (Body (Body b GhcPs) GhcPs) GhcPs)))] ~ SrcSpanAnnLW
    
    1736
    +                       (LocatedA (Body (Body (Body b GhcPs) GhcPs) GhcPs)))] ~ SrcSpanAnnA
    
    1737 1737
         )
    
    1738 1738
     
    
    1739 1739
     -- | Disambiguate constructs that may appear when we do not know ahead of time whether we are
    
    ... ... @@ -1795,8 +1795,9 @@ class (b ~ (Body b) GhcPs, AnnoBody b) => DisambECP b where
    1795 1795
       -- | Disambiguate "do { ... }" (do notation)
    
    1796 1796
       mkHsDoPV ::
    
    1797 1797
         SrcSpan ->
    
    1798
    +    (EpToken "{", [EpToken ";"], EpToken "}") ->
    
    1798 1799
         Maybe ModuleName ->
    
    1799
    -    LocatedLW [LStmt GhcPs (LocatedA b)] ->
    
    1800
    +    LocatedA [LStmt GhcPs (LocatedA b)] ->
    
    1800 1801
         EpaLocation -> -- Token
    
    1801 1802
         EpaLocation -> -- Anchor
    
    1802 1803
         PV (LocatedA b)
    
    ... ... @@ -1948,10 +1949,10 @@ instance DisambECP (HsCmd GhcPs) where
    1948 1949
         checkDoAndIfThenElse PsErrSemiColonsInCondCmd c semi1 a semi2 b
    
    1949 1950
         !cs <- getCommentsFor l
    
    1950 1951
         return $ L (EpAnn (spanAsAnchor l) noAnn cs) (mkHsCmdIf c a b anns)
    
    1951
    -  mkHsDoPV l Nothing stmts tok_loc anc = do
    
    1952
    +  mkHsDoPV l (ob,semis,cb) Nothing stmts tok_loc anc = do
    
    1952 1953
         !cs <- getCommentsFor l
    
    1953
    -    return $ L (EpAnn (spanAsAnchor l) noAnn cs) (HsCmdDo (AnnList (Just anc) ListNone [] tok_loc []) stmts)
    
    1954
    -  mkHsDoPV l (Just m)    _ _ _ = addFatalError $ mkPlainErrorMsgEnvelope l $ PsErrQualifiedDoInCmd m
    
    1954
    +    return $ L (EpAnn (spanAsAnchor l) noAnn cs) (HsCmdDo (AnnList (Just anc) (ListBraces ob cb) semis tok_loc []) stmts)
    
    1955
    +  mkHsDoPV l _ (Just m) _ _ _ = addFatalError $ mkPlainErrorMsgEnvelope l $ PsErrQualifiedDoInCmd m
    
    1955 1956
       mkHsParPV l lpar c rpar = do
    
    1956 1957
         !cs <- getCommentsFor l
    
    1957 1958
         return $ L (EpAnn (spanAsAnchor l) noAnn cs) (HsCmdPar (lpar, rpar) c)
    
    ... ... @@ -2047,9 +2048,9 @@ instance DisambECP (HsExpr GhcPs) where
    2047 2048
         checkDoAndIfThenElse PsErrSemiColonsInCondExpr c semi1 a semi2 b
    
    2048 2049
         !cs <- getCommentsFor l
    
    2049 2050
         return $ L (EpAnn (spanAsAnchor l) noAnn cs) (mkHsIf c a b anns)
    
    2050
    -  mkHsDoPV l mod stmts loc_tok anc = do
    
    2051
    +  mkHsDoPV l (ob,semis,cb) mod stmts loc_tok anc = do
    
    2051 2052
         !cs <- getCommentsFor l
    
    2052
    -    return $ L (EpAnn (spanAsAnchor l) noAnn cs) (HsDo (AnnList (Just anc) ListNone [] loc_tok []) (DoExpr mod) stmts)
    
    2053
    +    return $ L (EpAnn (spanAsAnchor l) noAnn cs) (HsDo (AnnList (Just anc) (ListBraces ob cb) semis loc_tok []) (DoExpr mod) stmts)
    
    2053 2054
       mkHsParPV l lpar e rpar = do
    
    2054 2055
         !cs <- getCommentsFor l
    
    2055 2056
         return $ L (EpAnn (spanAsAnchor l) noAnn cs) (HsPar (lpar, rpar) e)
    
    ... ... @@ -2145,7 +2146,7 @@ instance DisambECP (PatBuilder GhcPs) where
    2145 2146
         !cs <- getCommentsFor (locA l)
    
    2146 2147
         return $ L (addCommentsToEpAnn l cs) (PatBuilderAppType p at (mkHsTyPat t))
    
    2147 2148
       mkHsIfPV l _ _ _ _ _ _ = addFatalError $ mkPlainErrorMsgEnvelope l PsErrIfThenElseInPat
    
    2148
    -  mkHsDoPV l _ _ _ _    = addFatalError $ mkPlainErrorMsgEnvelope l PsErrDoNotationInPat
    
    2149
    +  mkHsDoPV l _ _ _ _ _   = addFatalError $ mkPlainErrorMsgEnvelope l PsErrDoNotationInPat
    
    2149 2150
       mkHsParPV l lpar p rpar   = return $ L (noAnnSrcSpan l) (PatBuilderPar lpar p rpar)
    
    2150 2151
       mkHsVarPV v@(getLoc -> l) = return $ L (l2l l) (PatBuilderVar v)
    
    2151 2152
       mkHsLitPV lit@(L l a) = do
    

  • compiler/GHC/Parser/Types.hs
    ... ... @@ -110,7 +110,7 @@ instance Outputable DataConBuilder where
    110 110
       ppr (InfixDataConBuilder lhs data_con rhs) =
    
    111 111
         ppr lhs <+> ppr data_con <+> ppr rhs
    
    112 112
     
    
    113
    -type instance Anno [LocatedA (StmtLR GhcPs GhcPs (LocatedA (PatBuilder GhcPs)))] = SrcSpanAnnLW
    
    113
    +type instance Anno [LocatedA (StmtLR GhcPs GhcPs (LocatedA (PatBuilder GhcPs)))] = SrcSpanAnnA
    
    114 114
     
    
    115 115
     data ExplicitNamespaceKeyword
    
    116 116
       = ExplicitTypeNamespace !(EpToken "type")
    

  • compiler/GHC/Tc/Gen/Match.hs
    ... ... @@ -376,7 +376,7 @@ tcGRHSNE ctxt tc_body grhss res_ty
    376 376
     -}
    
    377 377
     
    
    378 378
     tcDoStmts :: HsDoFlavour
    
    379
    -          -> LocatedLW [LStmt GhcRn (LHsExpr GhcRn)]
    
    379
    +          -> LocatedA [LStmt GhcRn (LHsExpr GhcRn)]
    
    380 380
               -> ExpRhoType
    
    381 381
               -> TcM (HsExpr GhcTc)          -- Returns a HsDo
    
    382 382
     tcDoStmts ListComp (L l stmts) res_ty
    

  • testsuite/tests/parser/should_compile/DumpParsedAstComments.stderr
    ... ... @@ -287,7 +287,9 @@
    287 287
                      (AnnList
    
    288 288
                       (Just
    
    289 289
                        (EpaSpan { DumpParsedAstComments.hs:16:3 }))
    
    290
    -                  (ListNone)
    
    290
    +                  (ListBraces
    
    291
    +                   (NoEpTok)
    
    292
    +                   (NoEpTok))
    
    291 293
                       []
    
    292 294
                       (EpaSpan { DumpParsedAstComments.hs:14:7-8 })
    
    293 295
                       [])
    
    ... ... @@ -296,12 +298,7 @@
    296 298
                      (L
    
    297 299
                       (EpAnn
    
    298 300
                        (EpaSpan { DumpParsedAstComments.hs:16:3 })
    
    299
    -                   (AnnList
    
    300
    -                    (Just
    
    301
    -                     (EpaSpan { DumpParsedAstComments.hs:16:3 }))
    
    302
    -                    (ListNone)
    
    303
    -                    []
    
    304
    -                    (NoEpTok)
    
    301
    +                   (AnnListItem
    
    305 302
                         [])
    
    306 303
                        (EpaComments
    
    307 304
                         []))
    

  • testsuite/tests/parser/should_compile/DumpSemis.stderr
    ... ... @@ -337,7 +337,9 @@
    337 337
                      (AnnList
    
    338 338
                       (Just
    
    339 339
                        (EpaSpan { DumpSemis.hs:(11,3)-(12,3) }))
    
    340
    -                  (ListNone)
    
    340
    +                  (ListBraces
    
    341
    +                   (NoEpTok)
    
    342
    +                   (NoEpTok))
    
    341 343
                       []
    
    342 344
                       (EpaSpan { DumpSemis.hs:10:7-8 })
    
    343 345
                       [])
    
    ... ... @@ -346,12 +348,7 @@
    346 348
                      (L
    
    347 349
                       (EpAnn
    
    348 350
                        (EpaSpan { DumpSemis.hs:(11,3)-(12,3) })
    
    349
    -                   (AnnList
    
    350
    -                    (Just
    
    351
    -                     (EpaSpan { DumpSemis.hs:(11,3)-(12,3) }))
    
    352
    -                    (ListNone)
    
    353
    -                    []
    
    354
    -                    (NoEpTok)
    
    351
    +                   (AnnListItem
    
    355 352
                         [])
    
    356 353
                        (EpaComments
    
    357 354
                         []))
    
    ... ... @@ -375,30 +372,25 @@
    375 372
                            (AnnList
    
    376 373
                             (Just
    
    377 374
                              (EpaSpan { DumpSemis.hs:11:6-15 }))
    
    378
    -                        (ListNone)
    
    379
    -                        []
    
    375
    +                        (ListBraces
    
    376
    +                         (EpTok (EpaSpan { DumpSemis.hs:11:6 }))
    
    377
    +                         (EpTok (EpaSpan { DumpSemis.hs:11:15 })))
    
    378
    +                        [(EpTok
    
    379
    +                          (EpaSpan { DumpSemis.hs:11:8 }))
    
    380
    +                        ,(EpTok
    
    381
    +                          (EpaSpan { DumpSemis.hs:11:9 }))
    
    382
    +                        ,(EpTok
    
    383
    +                          (EpaSpan { DumpSemis.hs:11:10 }))
    
    384
    +                        ,(EpTok
    
    385
    +                          (EpaSpan { DumpSemis.hs:11:11 }))]
    
    380 386
                             (EpaSpan { DumpSemis.hs:11:3-4 })
    
    381 387
                             [])
    
    382 388
                            (DoExpr
    
    383 389
                             (Nothing))
    
    384 390
                            (L
    
    385 391
                             (EpAnn
    
    386
    -                         (EpaSpan { DumpSemis.hs:11:6-15 })
    
    387
    -                         (AnnList
    
    388
    -                          (Just
    
    389
    -                           (EpaSpan { DumpSemis.hs:11:8-13 }))
    
    390
    -                          (ListBraces
    
    391
    -                           (EpTok (EpaSpan { DumpSemis.hs:11:6 }))
    
    392
    -                           (EpTok (EpaSpan { DumpSemis.hs:11:15 })))
    
    393
    -                          [(EpTok
    
    394
    -                            (EpaSpan { DumpSemis.hs:11:8 }))
    
    395
    -                          ,(EpTok
    
    396
    -                            (EpaSpan { DumpSemis.hs:11:9 }))
    
    397
    -                          ,(EpTok
    
    398
    -                            (EpaSpan { DumpSemis.hs:11:10 }))
    
    399
    -                          ,(EpTok
    
    400
    -                            (EpaSpan { DumpSemis.hs:11:11 }))]
    
    401
    -                          (NoEpTok)
    
    392
    +                         (EpaSpan { DumpSemis.hs:11:8-13 })
    
    393
    +                         (AnnListItem
    
    402 394
                               [])
    
    403 395
                              (EpaComments
    
    404 396
                               []))
    
    ... ... @@ -649,26 +641,21 @@
    649 641
                      (AnnList
    
    650 642
                       (Just
    
    651 643
                        (EpaSpan { DumpSemis.hs:(16,3)-(19,3) }))
    
    652
    -                  (ListNone)
    
    653
    -                  []
    
    644
    +                  (ListBraces
    
    645
    +                   (EpTok (EpaSpan { DumpSemis.hs:16:3 }))
    
    646
    +                   (EpTok (EpaSpan { DumpSemis.hs:19:3 })))
    
    647
    +                  [(EpTok
    
    648
    +                    (EpaSpan { DumpSemis.hs:16:5 }))
    
    649
    +                  ,(EpTok
    
    650
    +                    (EpaSpan { DumpSemis.hs:16:8 }))]
    
    654 651
                       (EpaSpan { DumpSemis.hs:15:7-8 })
    
    655 652
                       [])
    
    656 653
                      (DoExpr
    
    657 654
                       (Nothing))
    
    658 655
                      (L
    
    659 656
                       (EpAnn
    
    660
    -                   (EpaSpan { DumpSemis.hs:(16,3)-(19,3) })
    
    661
    -                   (AnnList
    
    662
    -                    (Just
    
    663
    -                     (EpaSpan { DumpSemis.hs:(16,5)-(18,5) }))
    
    664
    -                    (ListBraces
    
    665
    -                     (EpTok (EpaSpan { DumpSemis.hs:16:3 }))
    
    666
    -                     (EpTok (EpaSpan { DumpSemis.hs:19:3 })))
    
    667
    -                    [(EpTok
    
    668
    -                      (EpaSpan { DumpSemis.hs:16:5 }))
    
    669
    -                    ,(EpTok
    
    670
    -                      (EpaSpan { DumpSemis.hs:16:8 }))]
    
    671
    -                    (NoEpTok)
    
    657
    +                   (EpaSpan { DumpSemis.hs:(16,5)-(18,5) })
    
    658
    +                   (AnnListItem
    
    672 659
                         [])
    
    673 660
                        (EpaComments
    
    674 661
                         []))
    
    ... ... @@ -913,26 +900,21 @@
    913 900
                      (AnnList
    
    914 901
                       (Just
    
    915 902
                        (EpaSpan { DumpSemis.hs:22:10-30 }))
    
    916
    -                  (ListNone)
    
    917
    -                  []
    
    903
    +                  (ListBraces
    
    904
    +                   (EpTok (EpaSpan { DumpSemis.hs:22:10 }))
    
    905
    +                   (EpTok (EpaSpan { DumpSemis.hs:22:30 })))
    
    906
    +                  [(EpTok
    
    907
    +                    (EpaSpan { DumpSemis.hs:22:12 }))
    
    908
    +                  ,(EpTok
    
    909
    +                    (EpaSpan { DumpSemis.hs:22:13 }))]
    
    918 910
                       (EpaSpan { DumpSemis.hs:22:7-8 })
    
    919 911
                       [])
    
    920 912
                      (DoExpr
    
    921 913
                       (Nothing))
    
    922 914
                      (L
    
    923 915
                       (EpAnn
    
    924
    -                   (EpaSpan { DumpSemis.hs:22:10-30 })
    
    925
    -                   (AnnList
    
    926
    -                    (Just
    
    927
    -                     (EpaSpan { DumpSemis.hs:22:12-28 }))
    
    928
    -                    (ListBraces
    
    929
    -                     (EpTok (EpaSpan { DumpSemis.hs:22:10 }))
    
    930
    -                     (EpTok (EpaSpan { DumpSemis.hs:22:30 })))
    
    931
    -                    [(EpTok
    
    932
    -                      (EpaSpan { DumpSemis.hs:22:12 }))
    
    933
    -                    ,(EpTok
    
    934
    -                      (EpaSpan { DumpSemis.hs:22:13 }))]
    
    935
    -                    (NoEpTok)
    
    916
    +                   (EpaSpan { DumpSemis.hs:22:12-28 })
    
    917
    +                   (AnnListItem
    
    936 918
                         [])
    
    937 919
                        (EpaComments
    
    938 920
                         []))
    

  • testsuite/tests/printer/Test20297.stdout
    ... ... @@ -390,7 +390,9 @@
    390 390
                                 (AnnList
    
    391 391
                                  (Just
    
    392 392
                                   (EpaSpan { Test20297.hs:11:22-26 }))
    
    393
    -                             (ListNone)
    
    393
    +                             (ListBraces
    
    394
    +                              (NoEpTok)
    
    395
    +                              (NoEpTok))
    
    394 396
                                  []
    
    395 397
                                  (EpaSpan { Test20297.hs:11:19-20 })
    
    396 398
                                  [])
    
    ... ... @@ -399,12 +401,7 @@
    399 401
                                 (L
    
    400 402
                                  (EpAnn
    
    401 403
                                   (EpaSpan { Test20297.hs:11:22-26 })
    
    402
    -                              (AnnList
    
    403
    -                               (Just
    
    404
    -                                (EpaSpan { Test20297.hs:11:22-26 }))
    
    405
    -                               (ListNone)
    
    406
    -                               []
    
    407
    -                               (NoEpTok)
    
    404
    +                              (AnnListItem
    
    408 405
                                    [])
    
    409 406
                                   (EpaComments
    
    410 407
                                    []))
    
    ... ... @@ -817,7 +814,9 @@
    817 814
                                 (AnnList
    
    818 815
                                  (Just
    
    819 816
                                   (EpaSpan { Test20297.ppr.hs:9:20-24 }))
    
    820
    -                             (ListNone)
    
    817
    +                             (ListBraces
    
    818
    +                              (NoEpTok)
    
    819
    +                              (NoEpTok))
    
    821 820
                                  []
    
    822 821
                                  (EpaSpan { Test20297.ppr.hs:9:17-18 })
    
    823 822
                                  [])
    
    ... ... @@ -826,12 +825,7 @@
    826 825
                                 (L
    
    827 826
                                  (EpAnn
    
    828 827
                                   (EpaSpan { Test20297.ppr.hs:9:20-24 })
    
    829
    -                              (AnnList
    
    830
    -                               (Just
    
    831
    -                                (EpaSpan { Test20297.ppr.hs:9:20-24 }))
    
    832
    -                               (ListNone)
    
    833
    -                               []
    
    834
    -                               (NoEpTok)
    
    828
    +                              (AnnListItem
    
    835 829
                                    [])
    
    836 830
                                   (EpaComments
    
    837 831
                                    []))
    

  • utils/check-exact/ExactPrint.hs
    ... ... @@ -1447,10 +1447,7 @@ instance (ExactPrint a) => ExactPrint (LocatedAn NoEpAnns a) where
    1447 1447
         a' <- markAnnotated a
    
    1448 1448
         return (L la a')
    
    1449 1449
     
    
    1450
    -instance (ExactPrint a) => ExactPrint [a] where
    
    1451
    -  getAnnotationEntry = const NoEntryVal
    
    1452
    -  setAnnotationAnchor ls _ _ _ = ls
    
    1453
    -  exact ls = mapM markAnnotated ls
    
    1450
    +-- ---------------------------------------------------------------------
    
    1454 1451
     
    
    1455 1452
     instance (ExactPrint a) => ExactPrint (Maybe a) where
    
    1456 1453
       getAnnotationEntry = const NoEntryVal
    
    ... ... @@ -1489,7 +1486,7 @@ instance ExactPrint (HsModule GhcPs) where
    1489 1486
                  Just exps -> do
    
    1490 1487
                    let (op,cp,tcs) = am_exports $ anns an0
    
    1491 1488
                    op' <- markEpToken op
    
    1492
    -               exps' <- markAnnotated exps
    
    1489
    +               exps' <- mapM markAnnotated exps
    
    1493 1490
                    tcs' <- mapM markEpToken tcs
    
    1494 1491
                    cp' <- markEpToken cp
    
    1495 1492
                    return (Just exps', an0 { anns = (anns an0) { am_exports = (op',cp',tcs')}})
    
    ... ... @@ -1570,7 +1567,7 @@ instance ExactPrint (LocatedP (WarningTxt GhcPs)) where
    1570 1567
         o' <- markAnnOpen'' o src "{-# WARNING"
    
    1571 1568
         mb_cat' <- markAnnotated mb_cat
    
    1572 1569
         os' <- markEpToken os
    
    1573
    -    ws' <- markAnnotated ws
    
    1570
    +    ws' <- mapM markAnnotated ws
    
    1574 1571
         cs' <- markEpToken cs
    
    1575 1572
         c' <- markEpToken c
    
    1576 1573
         return (L (EpAnn l (AnnPragma o' c' (os',cs') l1 l2 t m) css) (WarningTxt src mb_cat' ws'))
    
    ... ... @@ -1578,7 +1575,7 @@ instance ExactPrint (LocatedP (WarningTxt GhcPs)) where
    1578 1575
       exact (L (EpAnn l (AnnPragma o c (os,cs) l1 l2 t m) css) (DeprecatedTxt src ws)) = do
    
    1579 1576
         o' <- markAnnOpen'' o src "{-# DEPRECATED"
    
    1580 1577
         os' <- markEpToken os
    
    1581
    -    ws' <- markAnnotated ws
    
    1578
    +    ws' <- mapM markAnnotated ws
    
    1582 1579
         cs' <- markEpToken cs
    
    1583 1580
         c' <- markEpToken c
    
    1584 1581
         return (L (EpAnn l (AnnPragma o' c' (os',cs') l1 l2 t m) css) (DeprecatedTxt src ws'))
    
    ... ... @@ -1706,7 +1703,7 @@ instance ExactPrint HsDocString where
    1706 1703
         pe <- getPriorEndD
    
    1707 1704
         debugM $ "MultiLineDocString: (pe,x)=" ++ showAst (pe,x)
    
    1708 1705
         x' <- markAnnotated x
    
    1709
    -    xs' <- markAnnotated (map dedentDocChunk xs)
    
    1706
    +    xs' <- mapM markAnnotated (map dedentDocChunk xs)
    
    1710 1707
         return (MultiLineDocString decorator (x' :| xs'))
    
    1711 1708
       exact x = do
    
    1712 1709
         -- TODO: can this happen?
    
    ... ... @@ -1929,7 +1926,7 @@ instance ExactPrint (WarnDecls GhcPs) where
    1929 1926
     
    
    1930 1927
       exact (Warnings ((o,c),src) warns) = do
    
    1931 1928
         o' <- markAnnOpen'' o src "{-# WARNING" -- Note: might be {-# DEPRECATED
    
    1932
    -    warns' <- markAnnotated warns
    
    1929
    +    warns' <- mapM markAnnotated warns
    
    1933 1930
         c' <- markEpToken c
    
    1934 1931
         return (Warnings ((o',c'),src) warns')
    
    1935 1932
     
    
    ... ... @@ -1942,17 +1939,17 @@ instance ExactPrint (WarnDecl GhcPs) where
    1942 1939
       exact (Warning (o,c) ns_spec lns (WarningTxt src mb_cat ls )) = do
    
    1943 1940
         mb_cat' <- markAnnotated mb_cat
    
    1944 1941
         ns_spec' <- exactNsSpec ns_spec
    
    1945
    -    lns' <- markAnnotated lns
    
    1942
    +    lns' <- mapM markAnnotated lns
    
    1946 1943
         o' <- markEpToken o
    
    1947
    -    ls' <- markAnnotated ls
    
    1944
    +    ls' <- mapM markAnnotated ls
    
    1948 1945
         c' <- markEpToken c
    
    1949 1946
         return (Warning (o',c') ns_spec' lns' (WarningTxt src mb_cat' ls'))
    
    1950 1947
     
    
    1951 1948
       exact (Warning (o,c) ns_spec lns (DeprecatedTxt src ls)) = do
    
    1952 1949
         ns_spec' <- exactNsSpec ns_spec
    
    1953
    -    lns' <- markAnnotated lns
    
    1950
    +    lns' <- mapM markAnnotated lns
    
    1954 1951
         o' <- markEpToken o
    
    1955
    -    ls' <- markAnnotated ls
    
    1952
    +    ls' <- mapM markAnnotated ls
    
    1956 1953
         c' <- markEpToken c
    
    1957 1954
         return (Warning (o',c') ns_spec' lns' (DeprecatedTxt src ls'))
    
    1958 1955
     
    
    ... ... @@ -1996,7 +1993,7 @@ instance ExactPrint (RuleDecls GhcPs) where
    1996 1993
           case src of
    
    1997 1994
             NoSourceText      -> printStringAtAA o "{-# RULES"
    
    1998 1995
             SourceText srcTxt -> printStringAtAA o (unpackFS srcTxt)
    
    1999
    -    rules' <- markAnnotated rules
    
    1996
    +    rules' <- mapM markAnnotated rules
    
    2000 1997
         c' <- markEpToken c
    
    2001 1998
         return (HsRules ((o',c'),src) rules')
    
    2002 1999
     
    
    ... ... @@ -2188,7 +2185,7 @@ exactHsFamInstLHS ops cps thing bndrs typats fixity mb_ctxt = do
    2188 2185
         exact_pats ops0 cps0 pats = do
    
    2189 2186
           ops' <- mapM markEpToken ops0
    
    2190 2187
           thing' <- markAnnotated thing
    
    2191
    -      pats' <- markAnnotated pats
    
    2188
    +      pats' <- mapM markAnnotated pats
    
    2192 2189
           cps' <- mapM markEpToken cps0
    
    2193 2190
           return (ops', cps', thing', pats')
    
    2194 2191
     
    
    ... ... @@ -2318,7 +2315,7 @@ instance ExactPrint (HsBind GhcPs) where
    2318 2315
         return (FunBind x fun_id' matches')
    
    2319 2316
     
    
    2320 2317
       exact (PatBind x pat q grhss) = do
    
    2321
    -    q' <- markAnnotated q
    
    2318
    +    q' <- mapM markAnnotated q
    
    2322 2319
         pat' <- markAnnotated pat
    
    2323 2320
         grhss' <- markAnnotated grhss
    
    2324 2321
         return (PatBind x pat' q' grhss')
    
    ... ... @@ -2348,12 +2345,12 @@ instance ExactPrint (PatSynBind GhcPs GhcPs) where
    2348 2345
               return (psyn', InfixCon x v1' v2')
    
    2349 2346
             PrefixCon x vs -> do
    
    2350 2347
               psyn' <- markAnnotated psyn
    
    2351
    -          vs' <- markAnnotated vs
    
    2348
    +          vs' <- mapM markAnnotated vs
    
    2352 2349
               return (psyn', PrefixCon x vs')
    
    2353 2350
             RecCon (ao,ac) vs -> do
    
    2354 2351
               psyn' <- markAnnotated psyn
    
    2355 2352
               ao' <- markEpToken ao
    
    2356
    -          vs' <- markAnnotated vs
    
    2353
    +          vs' <- mapM markAnnotated vs
    
    2357 2354
               ac' <- markEpToken ac
    
    2358 2355
               return (psyn', RecCon (ao',ac') vs')
    
    2359 2356
     
    
    ... ... @@ -2424,7 +2421,7 @@ exactMatch (Match an mctxt pats grhss) = do
    2424 2421
                 epTokensToComments "(" opens
    
    2425 2422
                 epTokensToComments ")" closes
    
    2426 2423
                 fun' <- markAnnotated fun
    
    2427
    -            pats' <- markAnnotated pats
    
    2424
    +            pats' <- (mapM . mapM) markAnnotated pats
    
    2428 2425
                 return (FunRhs fun' fixity strictness (AnnFunRhs strict' [] []), pats')
    
    2429 2426
               Infix ->
    
    2430 2427
                 case pats of
    
    ... ... @@ -2445,11 +2442,11 @@ exactMatch (Match an mctxt pats grhss) = do
    2445 2442
                   _ -> panic "FunRhs"
    
    2446 2443
     
    
    2447 2444
           LamAlt v -> do
    
    2448
    -        pats' <- markAnnotated pats
    
    2445
    +        pats' <- (mapM . mapM) markAnnotated pats
    
    2449 2446
             return (LamAlt v, pats')
    
    2450 2447
     
    
    2451 2448
           CaseAlt -> do
    
    2452
    -        pats' <- markAnnotated pats
    
    2449
    +        pats' <- (mapM . mapM) markAnnotated pats
    
    2453 2450
             return (CaseAlt, pats')
    
    2454 2451
     
    
    2455 2452
           _ -> do
    
    ... ... @@ -2548,7 +2545,7 @@ instance ExactPrint (HsIPBinds GhcPs) where
    2548 2545
       setAnnotationAnchor a _ _ _ = a
    
    2549 2546
     
    
    2550 2547
       exact (IPBinds x binds) = setLayoutBoth $ do
    
    2551
    -      binds' <- markAnnotated binds
    
    2548
    +      binds' <- mapM markAnnotated binds
    
    2552 2549
           return (IPBinds x binds')
    
    2553 2550
     
    
    2554 2551
     -- ---------------------------------------------------------------------
    
    ... ... @@ -2617,13 +2614,13 @@ instance ExactPrint (Sig GhcPs) where
    2617 2614
       setAnnotationAnchor a _ _ _ = a
    
    2618 2615
     
    
    2619 2616
       exact (TypeSig (AnnSig dc mp md) mods vars ty)  = do
    
    2620
    -    mods' <- markAnnotated mods
    
    2617
    +    mods' <- mapM markAnnotated mods
    
    2621 2618
         (dc', vars', ty') <- exactVarSig dc vars ty
    
    2622 2619
         return (TypeSig (AnnSig dc' mp md) mods' vars' ty')
    
    2623 2620
     
    
    2624 2621
       exact (PatSynSig (AnnSig dc mp md) lns typ) = do
    
    2625 2622
         mp' <- mapM markEpToken mp
    
    2626
    -    lns' <- markAnnotated lns
    
    2623
    +    lns' <- mapM markAnnotated lns
    
    2627 2624
         dc' <- markEpUniToken dc
    
    2628 2625
         typ' <- markAnnotated typ
    
    2629 2626
         return (PatSynSig (AnnSig dc' mp' md) lns' typ')
    
    ... ... @@ -2645,7 +2642,7 @@ instance ExactPrint (Sig GhcPs) where
    2645 2642
         af' <- printStringAtAA af fixstr
    
    2646 2643
         ma' <- mapM (\l -> printStringAtAA l (sourceTextToString src (show v))) ma
    
    2647 2644
         ns' <- markAnnotated ns
    
    2648
    -    names' <- markAnnotated names
    
    2645
    +    names' <- mapM markAnnotated names
    
    2649 2646
         return (FixSig ((af',ma'),src) (FixitySig noExtField ns' names' (Fixity v fdir)))
    
    2650 2647
     
    
    2651 2648
       exact (InlineSig (o,c,act) ln inl) = do
    
    ... ... @@ -2660,7 +2657,7 @@ instance ExactPrint (Sig GhcPs) where
    2660 2657
         act' <- markActivation act (inlinePragmaActivation inl)
    
    2661 2658
         ln' <- markAnnotated ln
    
    2662 2659
         dc' <- traverse markEpUniToken dc
    
    2663
    -    typs' <- markAnnotated typs
    
    2660
    +    typs' <- mapM markAnnotated typs
    
    2664 2661
         c' <- markEpToken c
    
    2665 2662
         return (SpecSig (AnnSpecSig o' c' dc' act') ln' typs' inl)
    
    2666 2663
     
    
    ... ... @@ -2749,11 +2746,11 @@ instance ExactPrint (DefaultDecl GhcPs) where
    2749 2746
       setAnnotationAnchor a _ _ _ = a
    
    2750 2747
     
    
    2751 2748
       exact (DefaultDecl (d,op,cp) mods cl tys) = do
    
    2752
    -    mods' <- markAnnotated mods
    
    2749
    +    mods' <- mapM markAnnotated mods
    
    2753 2750
         d' <- markEpToken d
    
    2754 2751
         cl' <- markAnnotated cl
    
    2755 2752
         op' <- markEpToken op
    
    2756
    -    tys' <- markAnnotated tys
    
    2753
    +    tys' <- mapM markAnnotated tys
    
    2757 2754
         cp' <- markEpToken cp
    
    2758 2755
         return (DefaultDecl (d',op',cp') mods' cl' tys')
    
    2759 2756
     
    
    ... ... @@ -2792,10 +2789,10 @@ instance ExactPrint (BF.BooleanFormula GhcPs) where
    2792 2789
         x' <- markAnnotated x
    
    2793 2790
         return (BF.Var x')
    
    2794 2791
       exact (BF.Or ls)  = do
    
    2795
    -    ls' <- markAnnotated ls
    
    2792
    +    ls' <- mapM markAnnotated ls
    
    2796 2793
         return (BF.Or ls')
    
    2797 2794
       exact (BF.And ls) = do
    
    2798
    -    ls' <- markAnnotated ls
    
    2795
    +    ls' <- mapM markAnnotated ls
    
    2799 2796
         return (BF.And ls')
    
    2800 2797
       exact (BF.Parens x)  = do
    
    2801 2798
         x' <- markAnnotated x
    
    ... ... @@ -2992,13 +2989,13 @@ instance ExactPrint (HsExpr GhcPs) where
    2992 2989
     
    
    2993 2990
       exact (HsDo an do_or_list_comp stmts) = do
    
    2994 2991
         debugM $ "HsDo"
    
    2995
    -    (an',stmts') <- markAnnListA' an $ \a -> exactDo a do_or_list_comp stmts
    
    2992
    +    (an',stmts') <- exactDo an do_or_list_comp stmts
    
    2996 2993
         return (HsDo an' do_or_list_comp stmts')
    
    2997 2994
     
    
    2998 2995
       exact (ExplicitList an es) = do
    
    2999 2996
         debugM $ "ExplicitList start"
    
    3000 2997
         an0 <- markLensBracketsO' an lal_brackets
    
    3001
    -    es' <- markAnnotated es
    
    2998
    +    es' <- mapM markAnnotated es
    
    3002 2999
         an1 <- markLensBracketsC' an0 lal_brackets
    
    3003 3000
         debugM $ "ExplicitList end"
    
    3004 3001
         return (ExplicitList an1 es')
    
    ... ... @@ -3081,7 +3078,7 @@ instance ExactPrint (HsExpr GhcPs) where
    3081 3078
       exact (HsUntypedBracket a (DecBrL (o,c, (oc,cc)) e)) = do
    
    3082 3079
         o' <- markEpToken o
    
    3083 3080
         oc' <- markEpToken oc
    
    3084
    -    e' <- markAnnotated e
    
    3081
    +    e' <- mapM markAnnotated e
    
    3085 3082
         cc' <- markEpToken cc
    
    3086 3083
         c' <- markEpUniToken c
    
    3087 3084
         return (HsUntypedBracket a (DecBrL (o',c',(oc',cc')) e'))
    
    ... ... @@ -3108,9 +3105,9 @@ instance ExactPrint (HsExpr GhcPs) where
    3108 3105
         s' <- markAnnotated s
    
    3109 3106
         return (HsTypedSplice an s')
    
    3110 3107
     
    
    3111
    -  exact (HsUntypedSplice an s) = do
    
    3108
    +  exact (HsUntypedSplice x s) = do
    
    3112 3109
         s' <- markAnnotated s
    
    3113
    -    return (HsUntypedSplice an s')
    
    3110
    +    return (HsUntypedSplice x s')
    
    3114 3111
     
    
    3115 3112
       exact (HsProc (pr,r) p c) = do
    
    3116 3113
         debugM $ "HsProc start"
    
    ... ... @@ -3151,7 +3148,7 @@ instance ExactPrint (HsExpr GhcPs) where
    3151 3148
     
    
    3152 3149
       exact (HsQual (op,cp,da) ctxt body) = do
    
    3153 3150
         op' <- mapM markEpToken op
    
    3154
    -    ctxt' <- markAnnotated ctxt
    
    3151
    +    ctxt' <- mapM markAnnotated ctxt
    
    3155 3152
         cp' <- mapM markEpToken cp
    
    3156 3153
         da' <- markEpUniToken da
    
    3157 3154
         body' <- markAnnotated body
    
    ... ... @@ -3170,10 +3167,12 @@ instance ExactPrint (HsExpr GhcPs) where
    3170 3167
     exactDo :: (Monad m, Monoid w, ExactPrint (LocatedAn an a))
    
    3171 3168
             => AnnList EpaLocation -> HsDoFlavour -> LocatedAn an a
    
    3172 3169
             -> EP w m (AnnList EpaLocation, LocatedAn an a)
    
    3173
    -exactDo an (DoExpr m)    stmts = exactMdo an m "do"          >>= \an0 -> markMaybeDodgyStmts an0 stmts
    
    3170
    +exactDo an (DoExpr m)    stmts = exactMdo an m "do" >>=
    
    3171
    +                                 \an0 -> markMaybeDodgyStmts an0 stmts
    
    3174 3172
     exactDo an GhciStmtCtxt  stmts = markLensFun an lal_rest (\l -> printStringAtAA l "do") >>=
    
    3175 3173
                                      \an0 -> markMaybeDodgyStmts an0 stmts
    
    3176
    -exactDo an (MDoExpr m)   stmts = exactMdo an m  "mdo" >>= \an0 -> markMaybeDodgyStmts an0 stmts
    
    3174
    +exactDo an (MDoExpr m)   stmts = exactMdo an m  "mdo" >>=
    
    3175
    +                                 \an0 -> markMaybeDodgyStmts an0 stmts
    
    3177 3176
     exactDo an ListComp      stmts = markMaybeDodgyStmts an stmts
    
    3178 3177
     exactDo an MonadComp     stmts = markMaybeDodgyStmts an stmts
    
    3179 3178
     
    
    ... ... @@ -3189,8 +3188,9 @@ markMaybeDodgyStmts :: (Monad m, Monoid w, ExactPrint (LocatedAn an a))
    3189 3188
     markMaybeDodgyStmts an stmts =
    
    3190 3189
       if notDodgy stmts
    
    3191 3190
         then do
    
    3192
    -      r <- markAnnotatedWithLayout stmts
    
    3193
    -      return (an, r)
    
    3191
    +      markAnnListA' an $ \a -> do
    
    3192
    +         r <- markAnnotatedWithLayout stmts
    
    3193
    +         return (a, r)
    
    3194 3194
         else return (an, stmts)
    
    3195 3195
     
    
    3196 3196
     notDodgy :: GenLocated (EpAnn ann) a -> Bool
    
    ... ... @@ -3277,7 +3277,7 @@ instance (ExactPrint body) => ExactPrint (HsRecFields GhcPs body) where
    3277 3277
       setAnnotationAnchor a _ _ _ = a
    
    3278 3278
       exact (HsRecFields (oc,cc) fields mdot) = do
    
    3279 3279
         oc' <- markEpToken oc
    
    3280
    -    fields' <- markAnnotated fields
    
    3280
    +    fields' <- mapM markAnnotated fields
    
    3281 3281
         mdot' <- case mdot of
    
    3282 3282
           Nothing -> return Nothing
    
    3283 3283
           Just (L ss d) -> do
    
    ... ... @@ -3329,11 +3329,11 @@ instance ExactPrint (LHsRecUpdFields GhcPs) where
    3329 3329
     
    
    3330 3330
       exact flds@(RegularRecUpdFields    { recUpdFields  = rbinds }) = do
    
    3331 3331
         debugM $ "RegularRecUpdFields"
    
    3332
    -    rbinds' <- markAnnotated rbinds
    
    3332
    +    rbinds' <- mapM markAnnotated rbinds
    
    3333 3333
         return $ flds { recUpdFields = rbinds' }
    
    3334 3334
       exact flds@(OverloadedRecUpdFields { olRecUpdFields = pbinds }) = do
    
    3335 3335
         debugM $ "OverloadedRecUpdFields"
    
    3336
    -    pbinds' <- markAnnotated pbinds
    
    3336
    +    pbinds' <- mapM markAnnotated pbinds
    
    3337 3337
         return $ flds { olRecUpdFields = pbinds' }
    
    3338 3338
     
    
    3339 3339
     -- ---------------------------------------------------------------------
    
    ... ... @@ -3419,11 +3419,11 @@ instance ExactPrint (HsCmd GhcPs) where
    3419 3419
           (Infix, (arg1:argrest)) -> do
    
    3420 3420
             arg1' <- markAnnotated arg1
    
    3421 3421
             e' <- markAnnotated e
    
    3422
    -        argrest' <- markAnnotated argrest
    
    3422
    +        argrest' <- mapM markAnnotated argrest
    
    3423 3423
             return (e', arg1':argrest')
    
    3424 3424
           (Prefix, _) -> do
    
    3425 3425
             e' <- markAnnotated e
    
    3426
    -        cs' <- markAnnotated cs
    
    3426
    +        cs' <- mapM markAnnotated cs
    
    3427 3427
             return (e', cs')
    
    3428 3428
           (Infix, []) -> error "Not possible"
    
    3429 3429
         an1 <- markLensBracketsC' an0 lal_brackets
    
    ... ... @@ -3475,19 +3475,22 @@ instance ExactPrint (HsCmd GhcPs) where
    3475 3475
           e' <- markAnnotated e
    
    3476 3476
           return (HsCmdLet (tkLet', tkIn') binds' e')
    
    3477 3477
     
    
    3478
    -  exact (HsCmdDo an es) = do
    
    3478
    +  exact (HsCmdDo an (L l es)) = do
    
    3479 3479
         debugM $ "HsCmdDo"
    
    3480
    -    an0 <- markLensFun an lal_rest (\l -> printStringAtAA l "do")
    
    3481
    -    es' <- markAnnotated es
    
    3482
    -    return (HsCmdDo an0 es')
    
    3480
    +    an0 <- markLensFun an lal_rest (\ll -> printStringAtAA ll "do")
    
    3481
    +    (an1,es') <- markAnnList' an0 $ do
    
    3482
    +      ee <- mapM markAnnotated es
    
    3483
    +      return ee
    
    3484
    +    -- es' <- mapM markAnnotated es
    
    3485
    +    return (HsCmdDo an1 (L l es'))
    
    3483 3486
     
    
    3484 3487
     -- ---------------------------------------------------------------------
    
    3485 3488
     
    
    3486 3489
     instance (
    
    3487 3490
       ExactPrint (LocatedA (body GhcPs)),
    
    3488 3491
                      Anno (StmtLR GhcPs GhcPs (LocatedA (body GhcPs))) ~ SrcSpanAnnA,
    
    3489
    -           Anno [GenLocated SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (body GhcPs)))] ~ SrcSpanAnnLW,
    
    3490
    -           (ExactPrint (LocatedLW [LocatedA (StmtLR GhcPs GhcPs (LocatedA (body GhcPs)))])))
    
    3492
    +           Anno [GenLocated SrcSpanAnnA (StmtLR GhcPs GhcPs (LocatedA (body GhcPs)))] ~ SrcSpanAnnA,
    
    3493
    +           (ExactPrint (LocatedA [LocatedA (StmtLR GhcPs GhcPs (LocatedA (body GhcPs)))])))
    
    3491 3494
        => ExactPrint (StmtLR GhcPs GhcPs (LocatedA (body GhcPs))) where
    
    3492 3495
       getAnnotationEntry _ = NoEntryVal
    
    3493 3496
       setAnnotationAnchor a _ _ _s = a
    
    ... ... @@ -3657,7 +3660,7 @@ instance ExactPrint (TyClDecl GhcPs) where
    3657 3660
                                  tcdModifiers = mods'})
    
    3658 3661
           where
    
    3659 3662
             top_matter = do
    
    3660
    -          mods' <- markAnnotated mods
    
    3663
    +          mods' <- mapM markAnnotated mods
    
    3661 3664
               epTokensToComments "(" ops
    
    3662 3665
               epTokensToComments ")" cps
    
    3663 3666
               c' <- markEpToken c
    
    ... ... @@ -3666,7 +3669,7 @@ instance ExactPrint (TyClDecl GhcPs) where
    3666 3669
                 then return (vb, fds)
    
    3667 3670
                 else do
    
    3668 3671
                   vb' <- markEpToken vb
    
    3669
    -              fds' <- markAnnotated fds
    
    3672
    +              fds' <- mapM markAnnotated fds
    
    3670 3673
                   return (vb', fds')
    
    3671 3674
               w' <- markEpToken w
    
    3672 3675
               return (mods', c', w', vb', fds', lclas', tyvars',context')
    
    ... ... @@ -3679,9 +3682,9 @@ instance ExactPrint (FunDep GhcPs) where
    3679 3682
       setAnnotationAnchor a _ _ _ = a
    
    3680 3683
     
    
    3681 3684
       exact (FunDep an ls rs') = do
    
    3682
    -    ls' <- markAnnotated ls
    
    3685
    +    ls' <- mapM markAnnotated ls
    
    3683 3686
         an0 <- markEpUniToken an
    
    3684
    -    rs'' <- markAnnotated rs'
    
    3687
    +    rs'' <- mapM markAnnotated rs'
    
    3685 3688
         return (FunDep an0 ls' rs'')
    
    3686 3689
     
    
    3687 3690
     -- ---------------------------------------------------------------------
    
    ... ... @@ -3723,7 +3726,7 @@ instance ExactPrint (FamilyDecl GhcPs) where
    3723 3726
                            dd' <- markEpToken dd
    
    3724 3727
                            return (dd', mb_eqns)
    
    3725 3728
                          Just eqns -> do
    
    3726
    -                       eqns' <- markAnnotated eqns
    
    3729
    +                       eqns' <- mapM markAnnotated eqns
    
    3727 3730
                            return (dd, Just eqns')
    
    3728 3731
                      cc' <- markEpToken cc
    
    3729 3732
                      return (w',oc',dd',cc', ClosedTypeFamily mb_eqns')
    
    ... ... @@ -3844,12 +3847,12 @@ exactVanillaDeclHead thing tvs@(HsQTvs { hsq_explicit = tyvars }) fixity context
    3844 3847
               varl' <- markAnnotated varl
    
    3845 3848
               thing' <- markAnnotated thing
    
    3846 3849
               hvarsr' <- markAnnotated hvarsr
    
    3847
    -          tvarsr' <- markAnnotated tvarsr
    
    3850
    +          tvarsr' <- mapM markAnnotated tvarsr
    
    3848 3851
               return (thing', varl':hvarsr':tvarsr')
    
    3849 3852
           | fixity == Infix = do
    
    3850 3853
               varl' <- markAnnotated varl
    
    3851 3854
               thing' <- markAnnotated thing
    
    3852
    -          varsr' <- markAnnotated varsr
    
    3855
    +          varsr' <- mapM markAnnotated varsr
    
    3853 3856
               return (thing', varl':varsr')
    
    3854 3857
           | otherwise = do
    
    3855 3858
               thing' <- markAnnotated thing
    
    ... ... @@ -3984,12 +3987,12 @@ instance ExactPrint (HsType GhcPs) where
    3984 3987
         return (HsListTy (o',c') t')
    
    3985 3988
       exact (HsTupleTy an con tys) = do
    
    3986 3989
         an0 <- markOpeningParen an
    
    3987
    -    tys' <- markAnnotated tys
    
    3990
    +    tys' <- mapM markAnnotated tys
    
    3988 3991
         an1 <- markClosingParen an0
    
    3989 3992
         return (HsTupleTy an1 con tys')
    
    3990 3993
       exact (HsSumTy an tys) = do
    
    3991 3994
         an0 <- markOpeningParen an
    
    3992
    -    tys' <- markAnnotated tys
    
    3995
    +    tys' <- mapM markAnnotated tys
    
    3993 3996
         an1 <- markClosingParen an0
    
    3994 3997
         return (HsSumTy an1 tys')
    
    3995 3998
       exact (HsOpTy x t1 lo t2) = do
    
    ... ... @@ -4030,7 +4033,7 @@ instance ExactPrint (HsType GhcPs) where
    4030 4033
                  then markEpToken sq
    
    4031 4034
                  else return sq
    
    4032 4035
         o' <- markEpToken o
    
    4033
    -    tys' <- markAnnotated tys
    
    4036
    +    tys' <- mapM markAnnotated tys
    
    4034 4037
         c' <- markEpToken c
    
    4035 4038
         return (HsExplicitListTy (sq',o',c') prom tys')
    
    4036 4039
       exact (HsExplicitTupleTy (sq, an) prom tys) = do
    
    ... ... @@ -4038,7 +4041,7 @@ instance ExactPrint (HsType GhcPs) where
    4038 4041
                   then markEpToken sq
    
    4039 4042
                   else return sq
    
    4040 4043
         an0 <- markOpeningParen an
    
    4041
    -    tys' <- markAnnotated tys
    
    4044
    +    tys' <- mapM markAnnotated tys
    
    4042 4045
         an1 <- markClosingParen an0
    
    4043 4046
         return (HsExplicitTupleTy (sq', an1) prom tys')
    
    4044 4047
       exact (HsTyLit an lit) = do
    
    ... ... @@ -4060,13 +4063,13 @@ instance ExactPrint (HsForAllTelescope GhcPs) where
    4060 4063
     
    
    4061 4064
       exact (HsForAllVis (EpAnn l (f,r) cs) bndrs)   = do
    
    4062 4065
         f' <- markEpUniToken f
    
    4063
    -    bndrs' <- markAnnotated bndrs
    
    4066
    +    bndrs' <- mapM markAnnotated bndrs
    
    4064 4067
         r' <- markEpUniToken r
    
    4065 4068
         return (HsForAllVis (EpAnn l (f',r') cs) bndrs')
    
    4066 4069
     
    
    4067 4070
       exact (HsForAllInvis (EpAnn l (f,d) cs) bndrs) = do
    
    4068 4071
         f' <- markEpUniToken f
    
    4069
    -    bndrs' <- markAnnotated bndrs
    
    4072
    +    bndrs' <- mapM markAnnotated bndrs
    
    4070 4073
         d' <- markEpToken d
    
    4071 4074
         return (HsForAllInvis (EpAnn l (f',d') cs) bndrs')
    
    4072 4075
     
    
    ... ... @@ -4119,7 +4122,7 @@ instance (ExactPrint a) => ExactPrint (HsContextDetails GhcPs a) where
    4119 4122
     
    
    4120 4123
       exact (HsContext (opens, closes) tys) = do
    
    4121 4124
         opens' <- mapM markEpToken opens
    
    4122
    -    tys' <- markAnnotated tys
    
    4125
    +    tys' <- mapM markAnnotated tys
    
    4123 4126
         closes' <- mapM markEpToken closes
    
    4124 4127
         return (HsContext (opens', closes') tys')
    
    4125 4128
     
    
    ... ... @@ -4135,7 +4138,7 @@ instance ExactPrint (DerivClauseTys GhcPs) where
    4135 4138
         return (DctSingle x ty')
    
    4136 4139
       exact (DctMulti (op,cp) tys) = do
    
    4137 4140
         op' <- markEpToken op
    
    4138
    -    tys' <- markAnnotated tys
    
    4141
    +    tys' <- mapM markAnnotated tys
    
    4139 4142
         cp' <- markEpToken cp
    
    4140 4143
         return (DctMulti (op',cp') tys')
    
    4141 4144
     
    
    ... ... @@ -4326,12 +4329,12 @@ instance ExactPrint (ConDecl GhcPs) where
    4326 4329
             return (con', InfixCon x t1' t2')
    
    4327 4330
           exact_details (PrefixCon x tys) = do
    
    4328 4331
             con' <- markAnnotated con
    
    4329
    -        tys' <- markAnnotated tys
    
    4332
    +        tys' <- mapM markAnnotated tys
    
    4330 4333
             return (con', PrefixCon x tys')
    
    4331 4334
           exact_details (RecCon (oc,cc) (L an fields)) = do
    
    4332 4335
             con' <- markAnnotated con
    
    4333 4336
             oc' <- markEpToken oc
    
    4334
    -        fields' <- markAnnotated fields
    
    4337
    +        fields' <- mapM markAnnotated fields
    
    4335 4338
             cc' <- markEpToken cc
    
    4336 4339
             return (con', RecCon (oc',cc') (L an fields'))
    
    4337 4340
     
    
    ... ... @@ -4365,7 +4368,7 @@ instance ExactPrint (ConDecl GhcPs) where
    4365 4368
                 return (PrefixConGADT x args0')
    
    4366 4369
               (RecConGADT (oc,cc,rarr) (L an fields)) -> do
    
    4367 4370
                 oc' <- markEpToken oc
    
    4368
    -            fields' <- markAnnotated fields
    
    4371
    +            fields' <- mapM markAnnotated fields
    
    4369 4372
                 cc' <- markEpToken cc
    
    4370 4373
                 rarr' <- markEpUniToken rarr
    
    4371 4374
                 return (RecConGADT (oc',cc',rarr') (L an fields'))
    
    ... ... @@ -4397,7 +4400,7 @@ instance ExactPrintTVFlag flag => ExactPrint (HsOuterTyVarBndrs flag GhcPs) wher
    4397 4400
       exact b@(HsOuterImplicit _) = pure b
    
    4398 4401
       exact (HsOuterExplicit (EpAnn l (f,d) cs) bndrs) = do
    
    4399 4402
         f' <- markEpUniToken f
    
    4400
    -    bndrs' <- markAnnotated bndrs
    
    4403
    +    bndrs' <- mapM markAnnotated bndrs
    
    4401 4404
         d' <- markEpToken d
    
    4402 4405
         return (HsOuterExplicit (EpAnn l (f',d') cs) bndrs')
    
    4403 4406
     
    
    ... ... @@ -4408,7 +4411,7 @@ instance ExactPrint (HsConDeclRecField GhcPs) where
    4408 4411
       setAnnotationAnchor a _ _ _ = a
    
    4409 4412
     
    
    4410 4413
       exact (HsConDeclRecField _ names ftype) = do
    
    4411
    -    names' <- markAnnotated names
    
    4414
    +    names' <- mapM markAnnotated names
    
    4412 4415
         ftype' <- markAnnotated ftype
    
    4413 4416
         return (HsConDeclRecField noExtField names' ftype')
    
    4414 4417
     
    
    ... ... @@ -4436,7 +4439,7 @@ markModifiedFunArrOf :: (Monad m, Monoid w, ExactPrint a)
    4436 4439
                          -> EP w m (HsModifiedFunArrOf a GhcPs, b)
    
    4437 4440
     markModifiedFunArrOf (HsModifiedFunArr _ mods arr) tyM = do
    
    4438 4441
       ty' <- if isColon then pure (Left ()) else Right <$> tyM
    
    4439
    -  mods' <- markAnnotated mods
    
    4442
    +  mods' <- mapM markAnnotated mods
    
    4440 4443
       arr' <- case arr of
    
    4441 4444
         HsStandardArr (EpArrow a) -> HsStandardArr . EpArrow <$> markEpUniToken a
    
    4442 4445
         HsStandardArr (EpColon c) -> HsStandardArr . EpColon <$> markEpUniToken c
    
    ... ... @@ -4530,46 +4533,47 @@ instance (ExactPrint (Match GhcPs (LocatedA body)))
    4530 4533
         an0 <- markLensFun' an lal_rest markEpToken
    
    4531 4534
         an1 <- markLensBracketsO an0 lal_brackets
    
    4532 4535
         an2 <- markEpAnnAllLT an1 lal_semis
    
    4533
    -    a' <- markAnnotated a
    
    4536
    +    a' <- mapM markAnnotated a
    
    4534 4537
         an3 <- markLensBracketsC an2 lal_brackets
    
    4535 4538
         return (L an3 a')
    
    4536 4539
     
    
    4537
    -instance ExactPrint (LocatedLW [LocatedA (StmtLR GhcPs GhcPs (LocatedA (HsExpr GhcPs)))]) where
    
    4538
    -  getAnnotationEntry = entryFromLocatedA
    
    4539
    -  setAnnotationAnchor = setAnchorAn
    
    4540
    -  exact (L an stmts) = do
    
    4540
    +instance ExactPrint [LocatedA (StmtLR GhcPs GhcPs (LocatedA (HsExpr GhcPs)))] where
    
    4541
    +  getAnnotationEntry _ = NoEntryVal
    
    4542
    +  setAnnotationAnchor a _ _ _ = a
    
    4543
    +  exact stmts = do
    
    4541 4544
         debugM $ "LocatedL [ExprLStmt"
    
    4542
    -    (an'', stmts') <- markAnnList an $ do
    
    4543
    -      case snocView stmts of
    
    4544
    -        Just (initStmts, ls@(L _ (LastStmt _ _body _ _))) -> do
    
    4545
    -          debugM $ "LocatedL [ExprLStmt: snocView"
    
    4546
    -          ls' <- markAnnotated ls
    
    4547
    -          initStmts' <- markAnnotated initStmts
    
    4548
    -          return (initStmts' ++ [ls'])
    
    4549
    -        _ -> do
    
    4550
    -          markAnnotated stmts
    
    4551
    -    return (L an'' stmts')
    
    4552
    -
    
    4553
    -instance ExactPrint (LocatedLW [LocatedA (StmtLR GhcPs GhcPs (LocatedA (HsCmd GhcPs)))]) where
    
    4554
    -  getAnnotationEntry = entryFromLocatedA
    
    4555
    -  setAnnotationAnchor = setAnchorAn
    
    4556
    -  exact (L ann es) = do
    
    4557
    -    debugM $ "LocatedL [CmdLStmt"
    
    4558
    -    an0 <- markLensBracketsO ann lal_brackets
    
    4559
    -    es' <- mapM markAnnotated es
    
    4560
    -    an1 <- markLensBracketsC an0 lal_brackets
    
    4561
    -    return (L an1 es')
    
    4545
    +    case snocView stmts of
    
    4546
    +      Just (initStmts, ls@(L _ (LastStmt _ _body _ _))) -> do
    
    4547
    +        debugM $ "LocatedL [ExprLStmt: snocView"
    
    4548
    +        ls' <- markAnnotated ls
    
    4549
    +        initStmts' <- markAnnotated initStmts
    
    4550
    +        return (initStmts' ++ [ls'])
    
    4551
    +      _ -> do
    
    4552
    +        stmts' <- mapM markAnnotated stmts
    
    4553
    +        return stmts'
    
    4554
    +
    
    4555
    +-- TODO: harmonise with prior, on payload
    
    4556
    +instance ExactPrint [LocatedA (StmtLR GhcPs GhcPs (LocatedA (HsCmd GhcPs)))] where
    
    4557
    +  getAnnotationEntry _ = NoEntryVal
    
    4558
    +  setAnnotationAnchor a _ _ _ = a
    
    4559
    +  exact stmts = do
    
    4560
    +    debugM $ "LocatedL [ExprLStmt"
    
    4561
    +    case snocView stmts of
    
    4562
    +      Just (initStmts, ls@(L _ (LastStmt _ _body _ _))) -> do
    
    4563
    +        debugM $ "LocatedL [ExprLStmt: snocView"
    
    4564
    +        ls' <- markAnnotated ls
    
    4565
    +        initStmts' <- markAnnotated initStmts
    
    4566
    +        return (initStmts' ++ [ls'])
    
    4567
    +      _ -> do
    
    4568
    +        stmts' <- markAnnotated stmts
    
    4569
    +        return stmts'
    
    4562 4570
     
    
    4563 4571
     instance ExactPrint (LocatedA [LocatedA (HsConDeclRecField GhcPs)]) where
    
    4564 4572
       getAnnotationEntry = entryFromLocatedA
    
    4565 4573
       setAnnotationAnchor = setAnchorAn
    
    4566 4574
       exact (L an fs) = do
    
    4567 4575
         debugM $ "LocatedCB [LHsConDeclRecField"
    
    4568
    -    -- let (oc,cc) = anns an
    
    4569
    -    -- oc' <- markEpToken oc
    
    4570 4576
         fs' <- mapM markAnnotated fs
    
    4571
    -    -- cc' <- markEpToken cc
    
    4572
    -    -- return (L (an { anns = (oc',cc')}) fs')
    
    4573 4577
         return (L an fs')
    
    4574 4578
     
    
    4575 4579
     instance ExactPrint (LocatedBF (BF.BooleanFormula GhcPs)) where
    
    ... ... @@ -4619,14 +4623,14 @@ instance ExactPrint (IE GhcPs) where
    4619 4623
         (dd',c', wc', withs') <-
    
    4620 4624
           case wc of
    
    4621 4625
             NoIEWildcard -> do
    
    4622
    -          withs'' <- markAnnotated withs
    
    4626
    +          withs'' <- mapM markAnnotated withs
    
    4623 4627
               return (dd, c, wc, withs'')
    
    4624 4628
             IEWildcard pos -> do
    
    4625 4629
               let (bs, as) = splitAt pos withs
    
    4626
    -          bs' <- markAnnotated bs
    
    4630
    +          bs' <- mapM markAnnotated bs
    
    4627 4631
               dd' <- markEpToken dd
    
    4628 4632
               c' <- markEpToken c
    
    4629
    -          as' <- markAnnotated as
    
    4633
    +          as' <- mapM markAnnotated as
    
    4630 4634
               return (dd',c', wc, bs'++as')
    
    4631 4635
         cp' <- markEpToken cp
    
    4632 4636
         doc' <- markAnnotated doc
    
    ... ... @@ -4719,12 +4723,12 @@ instance ExactPrint (Pat GhcPs) where
    4719 4723
         return (BangPat an0 pat')
    
    4720 4724
     
    
    4721 4725
       exact (ListPat an pats) = do
    
    4722
    -    (an', pats') <- markAnnList' an (markAnnotated pats)
    
    4726
    +    (an', pats') <- markAnnList' an (mapM markAnnotated pats)
    
    4723 4727
         return (ListPat an' pats')
    
    4724 4728
     
    
    4725 4729
       exact (TuplePat an pats boxity) = do
    
    4726 4730
         an0 <- markOpeningParen an
    
    4727
    -    pats' <- markAnnotated pats
    
    4731
    +    pats' <- mapM markAnnotated pats
    
    4728 4732
         an1 <- markClosingParen an0
    
    4729 4733
         return (TuplePat an1 pats' boxity)
    
    4730 4734
     
    
    ... ... @@ -4737,7 +4741,7 @@ instance ExactPrint (Pat GhcPs) where
    4737 4741
         return (SumPat an3 pat' alt arity)
    
    4738 4742
     
    
    4739 4743
       exact (OrPat an pats) = do
    
    4740
    -    pats' <- markAnnotated (NE.toList pats)
    
    4744
    +    pats' <- mapM markAnnotated (NE.toList pats)
    
    4741 4745
         return (OrPat an (NE.fromList pats'))
    
    4742 4746
     
    
    4743 4747
       exact (ConPat x con details) = do
    
    ... ... @@ -4783,7 +4787,7 @@ instance ExactPrint (Pat GhcPs) where
    4783 4787
         pure (InvisPat (tokat', spec) tp')
    
    4784 4788
     
    
    4785 4789
       exact (ModifiedPat x mods pat) = do
    
    4786
    -    mods' <- markAnnotated mods
    
    4790
    +    mods' <- mapM markAnnotated mods
    
    4787 4791
         pat' <- markAnnotated pat
    
    4788 4792
         return (ModifiedPat x mods' pat')
    
    4789 4793
     
    
    ... ... @@ -4878,7 +4882,7 @@ exactUserCon c details = do
    4878 4882
     exactConArgs :: (Monad m, Monoid w)
    
    4879 4883
       => HsConPatDetails GhcPs -> EP w m (HsConPatDetails GhcPs)
    
    4880 4884
     exactConArgs (PrefixCon x pats) = do
    
    4881
    -  pats' <- markAnnotated pats
    
    4885
    +  pats' <- mapM markAnnotated pats
    
    4882 4886
       return (PrefixCon x pats')
    
    4883 4887
     exactConArgs (InfixCon x p1 p2) = do
    
    4884 4888
       p1' <- markAnnotated p1