summaryrefslogtreecommitdiff
path: root/compiler/GHC/Hs
diff options
context:
space:
mode:
authorVladislav Zavialov <vlad.z.4096@gmail.com>2022-05-15 14:27:36 +0300
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-06-20 17:34:44 -0400
commitd24afd9d7139d7a62f3b465af1be50b25c15e5b5 (patch)
tree914187fdbd3161c1734765b7f81a0172faff3779 /compiler/GHC/Hs
parentb5590fff75496356b1817adc9de1f2d361a70dc5 (diff)
downloadhaskell-d24afd9d7139d7a62f3b465af1be50b25c15e5b5.tar.gz
HsToken for @-patterns and TypeApplications (#19623)
One more step towards the new design of EPA.
Diffstat (limited to 'compiler/GHC/Hs')
-rw-r--r--compiler/GHC/Hs/Expr.hs4
-rw-r--r--compiler/GHC/Hs/Instances.hs4
-rw-r--r--compiler/GHC/Hs/Pat.hs13
-rw-r--r--compiler/GHC/Hs/Syn/Type.hs4
-rw-r--r--compiler/GHC/Hs/Type.hs4
-rw-r--r--compiler/GHC/Hs/Utils.hs6
6 files changed, 20 insertions, 15 deletions
diff --git a/compiler/GHC/Hs/Expr.hs b/compiler/GHC/Hs/Expr.hs
index d664456654..12e9e2d81c 100644
--- a/compiler/GHC/Hs/Expr.hs
+++ b/compiler/GHC/Hs/Expr.hs
@@ -247,7 +247,7 @@ type instance XLamCase (GhcPass _) = EpAnn [AddEpAnn]
type instance XApp (GhcPass _) = EpAnnCO
-type instance XAppTypeE GhcPs = SrcSpan -- Where the `@` lives
+type instance XAppTypeE GhcPs = NoExtField
type instance XAppTypeE GhcRn = NoExtField
type instance XAppTypeE GhcTc = Type
@@ -730,7 +730,7 @@ ppr_apps :: (OutputableBndrId p)
-> SDoc
ppr_apps (HsApp _ (L _ fun) arg) args
= ppr_apps fun (Left arg : args)
-ppr_apps (HsAppType _ (L _ fun) arg) args
+ppr_apps (HsAppType _ (L _ fun) _ arg) args
= ppr_apps fun (Right arg : args)
ppr_apps fun args = hang (ppr_expr fun) 2 (fsep (map pp args))
where
diff --git a/compiler/GHC/Hs/Instances.hs b/compiler/GHC/Hs/Instances.hs
index 3f4c0b16bd..0a723cee11 100644
--- a/compiler/GHC/Hs/Instances.hs
+++ b/compiler/GHC/Hs/Instances.hs
@@ -431,6 +431,10 @@ deriving instance Data (Pat GhcTc)
deriving instance Data ConPatTc
+deriving instance Data (HsConPatTyArg GhcPs)
+deriving instance Data (HsConPatTyArg GhcRn)
+deriving instance Data (HsConPatTyArg GhcTc)
+
deriving instance (Data a, Data b) => Data (HsFieldBind a b)
deriving instance (Data body) => Data (HsRecFields GhcPs body)
diff --git a/compiler/GHC/Hs/Pat.hs b/compiler/GHC/Hs/Pat.hs
index f3e4fbe9c4..102587026e 100644
--- a/compiler/GHC/Hs/Pat.hs
+++ b/compiler/GHC/Hs/Pat.hs
@@ -28,6 +28,7 @@ module GHC.Hs.Pat (
XXPatGhcTc(..),
HsConPatDetails, hsConPatArgs,
+ HsConPatTyArg(..),
HsRecFields(..), HsFieldBind(..), LHsFieldBind,
HsRecField, LHsRecField,
HsRecUpdField, LHsRecUpdField,
@@ -94,7 +95,7 @@ type instance XLazyPat GhcPs = EpAnn [AddEpAnn] -- For '~'
type instance XLazyPat GhcRn = NoExtField
type instance XLazyPat GhcTc = NoExtField
-type instance XAsPat GhcPs = EpAnn [AddEpAnn] -- For '@'
+type instance XAsPat GhcPs = EpAnnCO
type instance XAsPat GhcRn = NoExtField
type instance XAsPat GhcTc = NoExtField
@@ -307,7 +308,7 @@ pprPat (VarPat _ lvar) = pprPatBndr (unLoc lvar)
pprPat (WildPat _) = char '_'
pprPat (LazyPat _ pat) = char '~' <> pprParendLPat appPrec pat
pprPat (BangPat _ pat) = char '!' <> pprParendLPat appPrec pat
-pprPat (AsPat _ name pat) = hcat [pprPrefixOcc (unLoc name), char '@',
+pprPat (AsPat _ name _ pat) = hcat [pprPrefixOcc (unLoc name), char '@',
pprParendLPat appPrec pat]
pprPat (ViewPat _ expr pat) = hcat [pprLExpr expr, text " -> ", ppr pat]
pprPat (ParPat _ _ pat _) = parens (ppr pat)
@@ -382,7 +383,7 @@ pprConArgs :: (OutputableBndrId p,
Outputable (Anno (IdGhcP p)))
=> HsConPatDetails (GhcPass p) -> SDoc
pprConArgs (PrefixCon ts pats) = fsep (pprTyArgs ts : map (pprParendLPat appPrec) pats)
- where pprTyArgs tyargs = fsep (map (\ty -> char '@' <> ppr ty) tyargs)
+ where pprTyArgs tyargs = fsep (map ppr tyargs)
pprConArgs (InfixCon p1 p2) = sep [ pprParendLPat appPrec p1
, pprParendLPat appPrec p2 ]
pprConArgs (RecCon rpats) = ppr rpats
@@ -475,7 +476,7 @@ looksLazyLPat = looksLazyPat . unLoc
looksLazyPat :: Pat (GhcPass p) -> Bool
looksLazyPat (ParPat _ _ p _) = looksLazyLPat p
-looksLazyPat (AsPat _ _ p) = looksLazyLPat p
+looksLazyPat (AsPat _ _ _ p) = looksLazyLPat p
looksLazyPat (BangPat {}) = False
looksLazyPat (VarPat {}) = False
looksLazyPat (WildPat {}) = False
@@ -542,7 +543,7 @@ isIrrefutableHsPat' is_strict = goL
| otherwise = True
go (BangPat _ pat) = goL pat
go (ParPat _ _ pat _) = goL pat
- go (AsPat _ _ pat) = goL pat
+ go (AsPat _ _ _ pat) = goL pat
go (ViewPat _ _ pat) = goL pat
go (SigPat _ pat _) = goL pat
go (TuplePat _ pats _) = all goL pats
@@ -699,7 +700,7 @@ collectEvVarsPat :: Pat GhcTc -> Bag EvVar
collectEvVarsPat pat =
case pat of
LazyPat _ p -> collectEvVarsLPat p
- AsPat _ _ p -> collectEvVarsLPat p
+ AsPat _ _ _ p -> collectEvVarsLPat p
ParPat _ _ p _ -> collectEvVarsLPat p
BangPat _ p -> collectEvVarsLPat p
ListPat _ ps -> unionManyBags $ map collectEvVarsLPat ps
diff --git a/compiler/GHC/Hs/Syn/Type.hs b/compiler/GHC/Hs/Syn/Type.hs
index 63b568df4a..2e40cec8d0 100644
--- a/compiler/GHC/Hs/Syn/Type.hs
+++ b/compiler/GHC/Hs/Syn/Type.hs
@@ -48,7 +48,7 @@ hsPatType (VarPat _ lvar) = idType (unLoc lvar)
hsPatType (BangPat _ pat) = hsLPatType pat
hsPatType (LazyPat _ pat) = hsLPatType pat
hsPatType (LitPat _ lit) = hsLitType lit
-hsPatType (AsPat _ var _) = idType (unLoc var)
+hsPatType (AsPat _ var _ _) = idType (unLoc var)
hsPatType (ViewPat ty _ _) = ty
hsPatType (ListPat ty _) = mkListTy ty
hsPatType (TuplePat tys _ bx) = mkTupleTy1 bx tys
@@ -101,7 +101,7 @@ hsExprType (HsLit _ lit) = hsLitType lit
hsExprType (HsLam _ (MG { mg_ext = match_group })) = matchGroupTcType match_group
hsExprType (HsLamCase _ _ (MG { mg_ext = match_group })) = matchGroupTcType match_group
hsExprType (HsApp _ f _) = funResultTy $ lhsExprType f
-hsExprType (HsAppType x f _) = piResultTy (lhsExprType f) x
+hsExprType (HsAppType x f _ _) = piResultTy (lhsExprType f) x
hsExprType (OpApp v _ _ _) = dataConCantHappen v
hsExprType (NegApp _ _ se) = syntaxExprType se
hsExprType (HsPar _ _ e _) = lhsExprType e
diff --git a/compiler/GHC/Hs/Type.hs b/compiler/GHC/Hs/Type.hs
index fe9aad3475..1635019dbe 100644
--- a/compiler/GHC/Hs/Type.hs
+++ b/compiler/GHC/Hs/Type.hs
@@ -203,7 +203,7 @@ type instance XHsWC GhcTc b = [Name]
type instance XXHsWildCardBndrs (GhcPass _) _ = DataConCantHappen
-type instance XHsPS GhcPs = EpAnn EpaLocation
+type instance XHsPS GhcPs = EpAnnCO
type instance XHsPS GhcRn = HsPSRn
type instance XHsPS GhcTc = HsPSRn
@@ -252,7 +252,7 @@ mkHsWildCardBndrs :: thing -> HsWildCardBndrs GhcPs thing
mkHsWildCardBndrs x = HsWC { hswc_body = x
, hswc_ext = noExtField }
-mkHsPatSigType :: EpAnn EpaLocation -> LHsType GhcPs -> HsPatSigType GhcPs
+mkHsPatSigType :: EpAnnCO -> LHsType GhcPs -> HsPatSigType GhcPs
mkHsPatSigType ann x = HsPS { hsps_ext = ann
, hsps_body = x }
diff --git a/compiler/GHC/Hs/Utils.hs b/compiler/GHC/Hs/Utils.hs
index 4dd0aab928..21e32825f5 100644
--- a/compiler/GHC/Hs/Utils.hs
+++ b/compiler/GHC/Hs/Utils.hs
@@ -244,7 +244,7 @@ mkHsAppsWith
mkHsAppsWith mkLocated = foldl' (mkHsAppWith mkLocated)
mkHsAppType :: LHsExpr GhcRn -> LHsWcType GhcRn -> LHsExpr GhcRn
-mkHsAppType e t = addCLocAA t_body e (HsAppType noExtField e paren_wct)
+mkHsAppType e t = addCLocAA t_body e (HsAppType noExtField e noHsTok paren_wct)
where
t_body = hswc_body t
paren_wct = t { hswc_body = parenthesizeHsType appPrec t_body }
@@ -1188,7 +1188,7 @@ collect_pat flag pat bndrs = case pat of
WildPat _ -> bndrs
LazyPat _ pat -> collect_lpat flag pat bndrs
BangPat _ pat -> collect_lpat flag pat bndrs
- AsPat _ a pat -> unXRec @p a : collect_lpat flag pat bndrs
+ AsPat _ a _ pat -> unXRec @p a : collect_lpat flag pat bndrs
ViewPat _ _ pat -> collect_lpat flag pat bndrs
ParPat _ _ pat _ -> collect_lpat flag pat bndrs
ListPat _ pats -> foldr (collect_lpat flag) bndrs pats
@@ -1584,7 +1584,7 @@ lPatImplicits = hs_lpat
hs_pat (LazyPat _ pat) = hs_lpat pat
hs_pat (BangPat _ pat) = hs_lpat pat
- hs_pat (AsPat _ _ pat) = hs_lpat pat
+ hs_pat (AsPat _ _ _ pat) = hs_lpat pat
hs_pat (ViewPat _ _ pat) = hs_lpat pat
hs_pat (ParPat _ _ pat _) = hs_lpat pat
hs_pat (ListPat _ pats) = hs_lpats pats