diff options
author | Simon Peyton Jones <simon.peytonjones@gmail.com> | 2023-01-24 10:29:27 +0000 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2023-01-27 23:54:55 -0500 |
commit | 0f25a13b7a59859d4be8be15af083e1c12ea6bc5 (patch) | |
tree | 716057ef329862204eb85084e618d5235710a2e7 | |
parent | faa300fb87f455980e390f7bf43c5a930e92f8e3 (diff) | |
download | haskell-0f25a13b7a59859d4be8be15af083e1c12ea6bc5.tar.gz |
Avoid orphans in the parser
This moves Anno instances for PatBuilder from GHC.Parser.PostProcess
to GHC.Parser.Types to avoid orphans.
-rw-r--r-- | compiler/GHC/Parser/PostProcess.hs | 5 | ||||
-rw-r--r-- | compiler/GHC/Parser/Types.hs | 6 |
2 files changed, 6 insertions, 5 deletions
diff --git a/compiler/GHC/Parser/PostProcess.hs b/compiler/GHC/Parser/PostProcess.hs index 9c0a5df0aa..48e4320faf 100644 --- a/compiler/GHC/Parser/PostProcess.hs +++ b/compiler/GHC/Parser/PostProcess.hs @@ -1817,11 +1817,6 @@ instance DisambECP (HsExpr GhcPs) where hsHoleExpr :: EpAnn EpAnnUnboundVar -> HsExpr GhcPs hsHoleExpr anns = HsUnboundVar anns (mkRdrUnqual (mkVarOccFS (fsLit "_"))) -type instance Anno (GRHS GhcPs (LocatedA (PatBuilder GhcPs))) = SrcAnn NoEpAnns -type instance Anno [LocatedA (Match GhcPs (LocatedA (PatBuilder GhcPs)))] = SrcSpanAnnL -type instance Anno (Match GhcPs (LocatedA (PatBuilder GhcPs))) = SrcSpanAnnA -type instance Anno (StmtLR GhcPs GhcPs (LocatedA (PatBuilder GhcPs))) = SrcSpanAnnA - instance DisambECP (PatBuilder GhcPs) where type Body (PatBuilder GhcPs) = PatBuilder ecpFromCmd' (L l c) = addFatalError $ mkPlainErrorMsgEnvelope (locA l) $ PsErrArrowCmdInPat c diff --git a/compiler/GHC/Parser/Types.hs b/compiler/GHC/Parser/Types.hs index 6ea37dda6d..2e38c22f69 100644 --- a/compiler/GHC/Parser/Types.hs +++ b/compiler/GHC/Parser/Types.hs @@ -61,6 +61,12 @@ data PatBuilder p | PatBuilderVar (LocatedN RdrName) | PatBuilderOverLit (HsOverLit GhcPs) +-- These instances are here so that they are not orphans +type instance Anno (GRHS GhcPs (LocatedA (PatBuilder GhcPs))) = SrcAnn NoEpAnns +type instance Anno [LocatedA (Match GhcPs (LocatedA (PatBuilder GhcPs)))] = SrcSpanAnnL +type instance Anno (Match GhcPs (LocatedA (PatBuilder GhcPs))) = SrcSpanAnnA +type instance Anno (StmtLR GhcPs GhcPs (LocatedA (PatBuilder GhcPs))) = SrcSpanAnnA + instance Outputable (PatBuilder GhcPs) where ppr (PatBuilderPat p) = ppr p ppr (PatBuilderPar _ (L _ p) _) = parens (ppr p) |