summaryrefslogtreecommitdiff
path: root/compiler/GHC/Hs
diff options
context:
space:
mode:
authorromes <rodrigo.m.mesquita@gmail.com>2022-05-22 21:05:32 +0200
committerromes <rodrigo.m.mesquita@gmail.com>2022-05-26 16:27:57 +0000
commit44bb71115bcf1edaee82fc75cbe07a3e242e9476 (patch)
treec850a97d6279f5a94b9ffab97bca24df9df5e142 /compiler/GHC/Hs
parentd0e4355af8c936a3ba831ecf6afa62b06475069f (diff)
downloadhaskell-44bb71115bcf1edaee82fc75cbe07a3e242e9476.tar.gz
TTG: Move MatchGroup Origin field and MatchGroupTc to GHC.Hswip/romes/ttg-matchgroup-origin
Diffstat (limited to 'compiler/GHC/Hs')
-rw-r--r--compiler/GHC/Hs/Expr.hs11
-rw-r--r--compiler/GHC/Hs/Syn/Type.hs2
-rw-r--r--compiler/GHC/Hs/Utils.hs11
3 files changed, 15 insertions, 9 deletions
diff --git a/compiler/GHC/Hs/Expr.hs b/compiler/GHC/Hs/Expr.hs
index 76699dc4f3..6f57eb5304 100644
--- a/compiler/GHC/Hs/Expr.hs
+++ b/compiler/GHC/Hs/Expr.hs
@@ -1292,10 +1292,17 @@ instance (OutputableBndrId p) => Outputable (HsCmdTop (GhcPass p)) where
************************************************************************
-}
-type instance XMG GhcPs b = NoExtField
-type instance XMG GhcRn b = NoExtField
+type instance XMG GhcPs b = Origin
+type instance XMG GhcRn b = Origin
type instance XMG GhcTc b = MatchGroupTc
+data MatchGroupTc
+ = MatchGroupTc
+ { mg_arg_tys :: [Scaled Type] -- Types of the arguments, t1..tn
+ , mg_res_ty :: Type -- Type of the result, tr
+ , mg_origin :: Origin -- Origin (Generated vs FromSource)
+ } deriving Data
+
type instance XXMatchGroup (GhcPass _) b = DataConCantHappen
type instance XCMatch (GhcPass _) b = EpAnn [AddEpAnn]
diff --git a/compiler/GHC/Hs/Syn/Type.hs b/compiler/GHC/Hs/Syn/Type.hs
index b93d87a9b3..30009ef400 100644
--- a/compiler/GHC/Hs/Syn/Type.hs
+++ b/compiler/GHC/Hs/Syn/Type.hs
@@ -192,7 +192,7 @@ lhsCmdTopType :: LHsCmdTop GhcTc -> Type
lhsCmdTopType (L _ (HsCmdTop (CmdTopTc _ ret_ty _) _)) = ret_ty
matchGroupTcType :: MatchGroupTc -> Type
-matchGroupTcType (MatchGroupTc args res) = mkVisFunTys args res
+matchGroupTcType (MatchGroupTc args res _) = mkVisFunTys args res
syntaxExprType :: SyntaxExpr GhcTc -> Type
syntaxExprType (SyntaxExprTc e _ _) = hsExprType e
diff --git a/compiler/GHC/Hs/Utils.hs b/compiler/GHC/Hs/Utils.hs
index e5bcd5959f..9d4e733375 100644
--- a/compiler/GHC/Hs/Utils.hs
+++ b/compiler/GHC/Hs/Utils.hs
@@ -200,7 +200,7 @@ unguardedRHS :: Anno (GRHS (GhcPass p) (LocatedA (body (GhcPass p))))
unguardedRHS an loc rhs = [L (noAnnSrcSpan loc) (GRHS an [] rhs)]
type AnnoBody p body
- = ( XMG (GhcPass p) (LocatedA (body (GhcPass p))) ~ NoExtField
+ = ( XMG (GhcPass p) (LocatedA (body (GhcPass p))) ~ Origin
, Anno [LocatedA (Match (GhcPass p) (LocatedA (body (GhcPass p))))] ~ SrcSpanAnnL
, Anno (Match (GhcPass p) (LocatedA (body (GhcPass p)))) ~ SrcSpanAnnA
)
@@ -209,9 +209,8 @@ mkMatchGroup :: AnnoBody p body
=> Origin
-> LocatedL [LocatedA (Match (GhcPass p) (LocatedA (body (GhcPass p))))]
-> MatchGroup (GhcPass p) (LocatedA (body (GhcPass p)))
-mkMatchGroup origin matches = MG { mg_ext = noExtField
- , mg_alts = matches
- , mg_origin = origin }
+mkMatchGroup origin matches = MG { mg_ext = origin
+ , mg_alts = matches }
mkLamCaseMatchGroup :: AnnoBody p body
=> Origin
@@ -257,7 +256,7 @@ mkHsAppType e t = addCLocAA t_body e (HsAppType noExtField e paren_wct)
mkHsAppTypes :: LHsExpr GhcRn -> [LHsWcType GhcRn] -> LHsExpr GhcRn
mkHsAppTypes = foldl' mkHsAppType
-mkHsLam :: (IsPass p, XMG (GhcPass p) (LHsExpr (GhcPass p)) ~ NoExtField)
+mkHsLam :: (IsPass p, XMG (GhcPass p) (LHsExpr (GhcPass p)) ~ Origin)
=> [LPat (GhcPass p)]
-> LHsExpr (GhcPass p)
-> LHsExpr (GhcPass p)
@@ -880,7 +879,7 @@ mkPatSynBind name details lpat dir anns = PatSynBind noExtField psb
-- |If any of the matches in the 'FunBind' are infix, the 'FunBind' is
-- considered infix.
isInfixFunBind :: forall id1 id2. UnXRec id2 => HsBindLR id1 id2 -> Bool
-isInfixFunBind (FunBind { fun_matches = MG _ matches _ })
+isInfixFunBind (FunBind { fun_matches = MG _ matches })
= any (isInfixMatch . unXRec @id2) (unXRec @id2 matches)
isInfixFunBind _ = False