Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC

Commits:

9 changed files:

Changes:

  • compiler/GHC/Data/BooleanFormula.hs
    ... ... @@ -25,7 +25,7 @@ import GHC.Types.Unique
    25 25
     import GHC.Types.Unique.Set
    
    26 26
     import GHC.Types.SrcLoc (unLoc)
    
    27 27
     import GHC.Utils.Outputable
    
    28
    -import GHC.Parser.Annotation ( SrcSpanAnnBF )
    
    28
    +import GHC.Parser.Annotation ( SrcSpanAnnA, EpToken(..) )
    
    29 29
     import GHC.Hs.Extension (GhcPass (..), OutputableBndrId)
    
    30 30
     import Language.Haskell.Syntax.Extension (Anno, LIdP, IdP,
    
    31 31
                                               noExtField, NoExtField, DataConCantHappen,
    
    ... ... @@ -38,12 +38,12 @@ import Language.Haskell.Syntax.BooleanFormula
    38 38
     -- Boolean formula type and smart constructors
    
    39 39
     ----------------------------------------------------------------------
    
    40 40
     
    
    41
    -type instance Anno (BooleanFormula (GhcPass p)) = SrcSpanAnnBF
    
    41
    +type instance Anno (BooleanFormula (GhcPass p)) = SrcSpanAnnA
    
    42 42
     
    
    43 43
     type instance XBFVar           (GhcPass _) = NoExtField
    
    44 44
     type instance XBFAnd           (GhcPass _) = NoExtField
    
    45 45
     type instance XBFOr            (GhcPass _) = NoExtField
    
    46
    -type instance XBFParens        (GhcPass _) = NoExtField
    
    46
    +type instance XBFParens        (GhcPass _) = (EpToken "(", EpToken ")")
    
    47 47
     type instance XXBooleanFormula (GhcPass _) = DataConCantHappen
    
    48 48
     
    
    49 49
     instance BooleanFormulaDefault (GhcPass p) where
    

  • compiler/GHC/Hs/Dump.hs
    ... ... @@ -97,7 +97,6 @@ showAstData bs ba a0 = blankLine $$ showAstData' a0
    97 97
                   `ext2Q` located
    
    98 98
                   `extQ` srcSpanAnnA
    
    99 99
                   `extQ` srcSpanAnnN
    
    100
    -              `extQ` srcSpanAnnBF
    
    101 100
     
    
    102 101
           where generic :: Data a => a -> SDoc
    
    103 102
                 generic t = parens $ text (showConstr (toConstr t))
    
    ... ... @@ -396,10 +395,6 @@ showAstData bs ba a0 = blankLine $$ showAstData' a0
    396 395
                 srcSpanAnnN :: EpAnn NameAnn -> SDoc
    
    397 396
                 srcSpanAnnN = locatedAnn'' (text "SrcSpanAnnN")
    
    398 397
     
    
    399
    -            srcSpanAnnBF :: EpAnn AnnBooleanFormula -> SDoc
    
    400
    -            srcSpanAnnBF = locatedAnn'' (text "SrcSpanAnnBF")
    
    401
    -
    
    402
    -
    
    403 398
                 locatedAnn'' :: forall a. (Typeable a, Data a)
    
    404 399
                   => SDoc -> EpAnn a -> SDoc
    
    405 400
                 locatedAnn'' tag ss = parens $
    

  • compiler/GHC/Iface/Ext/Ast.hs
    ... ... @@ -2081,7 +2081,7 @@ instance ToHie PendingRnSplice where
    2081 2081
       toHie (PendingRnSplice _ e) = toHie e
    
    2082 2082
     
    
    2083 2083
     instance (HiePass p, Data (IdGhcP p))
    
    2084
    -  => ToHie (GenLocated SrcSpanAnnBF (BooleanFormula (GhcPass p))) where
    
    2084
    +  => ToHie (GenLocated SrcSpanAnnA (BooleanFormula (GhcPass p))) where
    
    2085 2085
         toHie (L span form) =  concatM $ makeNode form (locA span) : case form of
    
    2086 2086
           Var _ a ->
    
    2087 2087
             [ toHie $ C Use a
    

  • compiler/GHC/Iface/Syntax.hs
    ... ... @@ -1330,7 +1330,7 @@ pprIfaceDecl ss decl@(IfaceClass { ifName = clas
    1330 1330
           fromIfaceBooleanFormula (IfVar nm   ) = Var    noExtField $ noLocA . mkUnboundName . mkVarOccFS . ifLclNameFS $ nm
    
    1331 1331
           fromIfaceBooleanFormula (IfAnd bfs  ) = And    noExtField $ map (noLocA . fromIfaceBooleanFormula) bfs
    
    1332 1332
           fromIfaceBooleanFormula (IfOr bfs   ) = Or     noExtField $ map (noLocA . fromIfaceBooleanFormula) bfs
    
    1333
    -      fromIfaceBooleanFormula (IfParens bf) = Parens noExtField $     (noLocA . fromIfaceBooleanFormula) bf
    
    1333
    +      fromIfaceBooleanFormula (IfParens bf) = Parens noAnn      $     (noLocA . fromIfaceBooleanFormula) bf
    
    1334 1334
     
    
    1335 1335
     
    
    1336 1336
           -- See Note [Suppressing binder signatures] in GHC.Iface.Type
    

  • compiler/GHC/IfaceToCore.hs
    ... ... @@ -121,7 +121,7 @@ import GHC.Types.Tickish
    121 121
     import GHC.Types.TyThing
    
    122 122
     import GHC.Types.Error
    
    123 123
     
    
    124
    -import GHC.Parser.Annotation (noLocA)
    
    124
    +import GHC.Parser.Annotation (noLocA, noAnn)
    
    125 125
     
    
    126 126
     import GHC.Fingerprint
    
    127 127
     
    
    ... ... @@ -885,7 +885,7 @@ tc_iface_decl _parent ignore_prags
    885 885
        tc_boolean_formula :: IfaceBooleanFormula -> IfL (BooleanFormula GhcRn)
    
    886 886
        tc_boolean_formula (IfAnd ibfs  ) = BF.And    NoExtField . map noLocA <$> traverse tc_boolean_formula ibfs
    
    887 887
        tc_boolean_formula (IfOr ibfs   ) = BF.Or     NoExtField . map noLocA <$> traverse tc_boolean_formula ibfs
    
    888
    -   tc_boolean_formula (IfParens ibf) = BF.Parens NoExtField .     noLocA <$>          tc_boolean_formula ibf
    
    888
    +   tc_boolean_formula (IfParens ibf) = BF.Parens noAnn      .     noLocA <$>          tc_boolean_formula ibf
    
    889 889
        tc_boolean_formula (IfVar nm    ) = BF.Var    NoExtField .     noLocA <$> (lookupIfaceTop . mkVarOccFS . ifLclNameFS $ nm)
    
    890 890
     
    
    891 891
        mk_sc_doc pred = text "Superclass" <+> ppr pred
    

  • compiler/GHC/Parser.y
    ... ... @@ -3820,7 +3820,7 @@ name_boolformula_opt :: { LBooleanFormula GhcPs }
    3820 3820
     name_boolformula :: { LBooleanFormula GhcPs }
    
    3821 3821
             : name_boolformula_and      { $1 }
    
    3822 3822
             | name_boolformula_and '|' name_boolformula
    
    3823
    -                           {% do { h <- addTrailingVbarBF $1 (epTok $2)
    
    3823
    +                           {% do { h <- addTrailingVbarA $1 (epTok $2)
    
    3824 3824
                                      ; return (sLLa $1 $> (Or noExtField [h,$3])) } }
    
    3825 3825
     
    
    3826 3826
     name_boolformula_and :: { LBooleanFormula GhcPs }
    
    ... ... @@ -3830,12 +3830,11 @@ name_boolformula_and :: { LBooleanFormula GhcPs }
    3830 3830
     name_boolformula_and_list :: { NonEmpty (LBooleanFormula GhcPs) }
    
    3831 3831
             : name_boolformula_atom                               { NE.singleton $1 }
    
    3832 3832
             | name_boolformula_atom ',' name_boolformula_and_list
    
    3833
    -            {% do { h <- addTrailingCommaBF $1 (epTok $2)
    
    3833
    +            {% do { h <- addTrailingCommaA $1 (epTok $2)
    
    3834 3834
                       ; return (h NE.<| $3) } }
    
    3835 3835
     
    
    3836 3836
     name_boolformula_atom :: { LBooleanFormula GhcPs }
    
    3837
    -        : '(' name_boolformula ')'  {% amsr (sLL $1 $> (Parens noExtField $2))
    
    3838
    -                                            (AnnBooleanFormula (epTok $1) (epTok $3) [])  }
    
    3837
    +        : '(' name_boolformula ')'  {% amsA' (sLL $1 $> (Parens (epTok $1, epTok $3) $2)) }
    
    3839 3838
             | name_var                  { sL1a $1 (Var noExtField $1) }
    
    3840 3839
     
    
    3841 3840
     namelist :: { Located [LocatedN RdrName] }
    
    ... ... @@ -4794,20 +4793,6 @@ addTrailingAnnA (L anns a) tok ta = do
    4794 4793
     
    
    4795 4794
     -- -------------------------------------
    
    4796 4795
     
    
    4797
    -addTrailingVbarBF :: MonadP m => LocatedBF a -> EpToken "|" -> m (LocatedBF a)
    
    4798
    -addTrailingVbarBF  la tok = addTrailingAnnBF la (AddVbarAnn tok)
    
    4799
    -
    
    4800
    -addTrailingCommaBF :: MonadP m => LocatedBF a -> EpToken "," -> m (LocatedBF a)
    
    4801
    -addTrailingCommaBF  la tok = addTrailingAnnBF la (AddCommaAnn tok)
    
    4802
    -
    
    4803
    -addTrailingAnnBF :: MonadP m => LocatedBF a -> TrailingAnn -> m (LocatedBF a)
    
    4804
    -addTrailingAnnBF (L anns a) ta = do
    
    4805
    -  !cs <- getCommentsFor (locA anns)
    
    4806
    -  let anns' = addTrailingAnnToBF ta cs anns
    
    4807
    -  return (L anns' a)
    
    4808
    -
    
    4809
    --- -------------------------------------
    
    4810
    -
    
    4811 4796
     -- Mostly use to add AnnComma, special case it to NOP if adding a zero-width annotation
    
    4812 4797
     addTrailingCommaN :: MonadP m => LocatedN a -> SrcSpan -> m (LocatedN a)
    
    4813 4798
     addTrailingCommaN (L anns a) span = do
    

  • compiler/GHC/Parser/Annotation.hs
    ... ... @@ -28,23 +28,19 @@ module GHC.Parser.Annotation (
    28 28
     
    
    29 29
       -- ** Annotations in 'GenLocated'
    
    30 30
       LocatedA, LocatedN, LocatedAn,
    
    31
    -  LocatedBF,
    
    32 31
       SrcSpanAnnA, SrcSpanAnnN,
    
    33
    -  SrcSpanAnnBF,
    
    34 32
     
    
    35 33
       -- ** Annotation data types used in 'GenLocated'
    
    36 34
     
    
    37 35
       AnnList(..), AnnListBrackets(..),
    
    38 36
       AnnParen(..),
    
    39 37
       AnnCType(..),AnnWarningTxt(..),AnnOverlap(..),AnnAnnDecl(..),AnnPragSCC(..),
    
    40
    -  AnnBooleanFormula(..),
    
    41 38
       NameAnn(..), NameAdornment(..),
    
    42 39
       NoEpAnns(..),
    
    43 40
     
    
    44 41
       -- ** Trailing annotations in lists
    
    45 42
       TrailingAnn(..), ta_location,
    
    46 43
       addTrailingAnnToA, addTrailingCommaToN,
    
    47
    -  addTrailingAnnToBF,
    
    48 44
       noTrailingN,
    
    49 45
     
    
    50 46
       -- ** Utilities for converting between different 'GenLocated' when
    
    ... ... @@ -430,8 +426,6 @@ emptyComments = EpaComments []
    430 426
     type LocatedA = GenLocated SrcSpanAnnA
    
    431 427
     type LocatedN = GenLocated SrcSpanAnnN
    
    432 428
     
    
    433
    -type LocatedBF = GenLocated SrcSpanAnnBF
    
    434
    -
    
    435 429
     -- | Annotation for items appearing in a list. They can have one or
    
    436 430
     -- more trailing punctuations items, such as commas or semicolons.
    
    437 431
     type SrcSpanAnnA = EpAnn [TrailingAnn]
    
    ... ... @@ -440,8 +434,6 @@ type SrcSpanAnnA = EpAnn [TrailingAnn]
    440 434
     -- on the context, such as backticks.
    
    441 435
     type SrcSpanAnnN = EpAnn NameAnn
    
    442 436
     
    
    443
    -type SrcSpanAnnBF = EpAnn AnnBooleanFormula
    
    444
    -
    
    445 437
     -- | General representation of a 'GenLocated' type carrying a
    
    446 438
     -- parameterised annotation type.
    
    447 439
     type LocatedAn an = GenLocated (EpAnn an)
    
    ... ... @@ -551,17 +543,6 @@ data AnnParen
    551 543
       | AnnParensHash   (EpToken "(#") (EpToken "#)") -- ^ '(#', '#)'
    
    552 544
       deriving Data
    
    553 545
     
    
    554
    --- ---------------------------------------------------------------------
    
    555
    --- | Exact print annotation for the 'BooleanFormula' data type.
    
    556
    -
    
    557
    -data AnnBooleanFormula
    
    558
    -  = AnnBooleanFormula {
    
    559
    -      abf_open      :: (EpToken "("), -- ^ opening parenthesis.
    
    560
    -      abf_close     :: (EpToken ")"), -- ^ closing parenthesis.
    
    561
    -      abf_trailing  :: ![TrailingAnn] -- ^ items appearing after the
    
    562
    -                                      -- item, such as '|', ','
    
    563
    -      } deriving (Data,Eq)
    
    564
    -
    
    565 546
     -- ---------------------------------------------------------------------
    
    566 547
     -- Annotations for names
    
    567 548
     -- ---------------------------------------------------------------------
    
    ... ... @@ -669,14 +650,6 @@ data AnnPragSCC
    669 650
     
    
    670 651
     -- ---------------------------------------------------------------------
    
    671 652
     
    
    672
    -addTrailingAnnToBF :: TrailingAnn -> EpAnnComments
    
    673
    -                  -> EpAnn AnnBooleanFormula -> EpAnn AnnBooleanFormula
    
    674
    -addTrailingAnnToBF t cs n = n { anns = addTrailing (anns n)
    
    675
    -                              , comments = comments n <> cs }
    
    676
    -  where
    
    677
    -    -- See Note [list append in addTrailing*]
    
    678
    -    addTrailing n = n { abf_trailing = abf_trailing n ++ [t]}
    
    679
    -
    
    680 653
     -- | Helper function used in the parser to add a 'TrailingAnn' items
    
    681 654
     -- to an existing annotation.
    
    682 655
     addTrailingAnnToA :: TrailingAnn -> EpAnnComments
    
    ... ... @@ -1030,9 +1003,6 @@ instance (NoAnn ann) => NoAnn (EpAnn ann) where
    1030 1003
     instance NoAnn NoEpAnns where
    
    1031 1004
       noAnn = NoEpAnns
    
    1032 1005
     
    
    1033
    -instance NoAnn AnnBooleanFormula where
    
    1034
    -  noAnn = AnnBooleanFormula noAnn noAnn []
    
    1035
    -
    
    1036 1006
     instance NoAnn AnnList where
    
    1037 1007
       noAnn = AnnList Nothing ListNone noAnn
    
    1038 1008
     
    

  • utils/check-exact/ExactPrint.hs
    ... ... @@ -353,10 +353,6 @@ instance HasTrailing (EpToken "{", EpToken "}") where
    353 353
       trailing _ = []
    
    354 354
       setTrailing a _ = a
    
    355 355
     
    
    356
    -instance HasTrailing (AnnBooleanFormula) where
    
    357
    -  trailing bf = abf_trailing bf
    
    358
    -  setTrailing a ts = a { abf_trailing = ts }
    
    359
    -
    
    360 356
     -- ---------------------------------------------------------------------
    
    361 357
     
    
    362 358
     fromAnn' :: (HasEntry a) => a -> Entry
    
    ... ... @@ -2731,9 +2727,11 @@ instance ExactPrint (BF.BooleanFormula GhcPs) where
    2731 2727
       exact (BF.And e ls) = do
    
    2732 2728
         ls' <- mapM markAnnotated ls
    
    2733 2729
         return (BF.And e ls')
    
    2734
    -  exact (BF.Parens e x)  = do
    
    2730
    +  exact (BF.Parens (o,c) x)  = do
    
    2731
    +    o' <- markEpToken o
    
    2735 2732
         x' <- markAnnotated x
    
    2736
    -    return (BF.Parens e x')
    
    2733
    +    c' <- markEpToken c
    
    2734
    +    return (BF.Parens (o',c') x')
    
    2737 2735
     
    
    2738 2736
     -- ---------------------------------------------------------------------
    
    2739 2737
     
    
    ... ... @@ -4474,17 +4472,6 @@ instance ExactPrint [LocatedA (StmtLR GhcPs GhcPs (LocatedA (HsCmd GhcPs)))] whe
    4474 4472
             stmts' <- markAnnotated stmts
    
    4475 4473
             return stmts'
    
    4476 4474
     
    
    4477
    -instance ExactPrint (LocatedBF (BF.BooleanFormula GhcPs)) where
    
    4478
    -  getAnnotationEntry = entryFromLocatedA
    
    4479
    -  setAnnotationAnchor = setAnchorAn
    
    4480
    -  exact (L an bf) = do
    
    4481
    -    debugM $ "LocatedCB [LBooleanFormula"
    
    4482
    -    let (AnnBooleanFormula op cp ta) = anns an
    
    4483
    -    op' <- markEpToken op
    
    4484
    -    bf' <- markAnnotated bf
    
    4485
    -    cp' <- markEpToken cp
    
    4486
    -    return (L (an {anns = AnnBooleanFormula op' cp' ta}) bf')
    
    4487
    -
    
    4488 4475
     instance ExactPrint [Located HsDocStringChunk] where
    
    4489 4476
       getAnnotationEntry _ = NoEntryVal
    
    4490 4477
       setAnnotationAnchor a _ _ _ = a
    

  • utils/haddock/haddock-api/src/Haddock/Types.hs
    ... ... @@ -834,7 +834,7 @@ type instance Anno (HsDecl DocNameI) = SrcSpanAnnA
    834 834
     type instance Anno (FamilyResultSig DocNameI) = EpAnn NoEpAnns
    
    835 835
     type instance Anno (HsOuterTyVarBndrs Specificity DocNameI) = SrcSpanAnnA
    
    836 836
     type instance Anno (HsSigType DocNameI) = SrcSpanAnnA
    
    837
    -type instance Anno (BooleanFormula DocNameI) = SrcSpanAnnBF
    
    837
    +type instance Anno (BooleanFormula DocNameI) = SrcSpanAnnA
    
    838 838
     type instance Anno (OverlapMode DocNameI) = SrcSpanAnnA
    
    839 839
     type instance Anno (CType DocNameI) = SrcSpanAnnA
    
    840 840
     type instance Anno (Header DocNameI) = SrcSpanAnnA
    
    ... ... @@ -1041,7 +1041,7 @@ type instance XXHsContextDetails DocNameI = DataConCantHappen
    1041 1041
     type instance XBFVar           DocNameI = NoExtField
    
    1042 1042
     type instance XBFAnd           DocNameI = NoExtField
    
    1043 1043
     type instance XBFOr            DocNameI = NoExtField
    
    1044
    -type instance XBFParens        DocNameI = NoExtField
    
    1044
    +type instance XBFParens        DocNameI = (EpToken "(", EpToken ")")
    
    1045 1045
     type instance XXBooleanFormula DocNameI = DataConCantHappen
    
    1046 1046
     
    
    1047 1047
     -----------------------------------------------------------------------------