summaryrefslogtreecommitdiff
path: root/compiler/Language/Haskell
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/Language/Haskell')
-rw-r--r--compiler/Language/Haskell/Syntax/Expr.hs2
-rw-r--r--compiler/Language/Haskell/Syntax/Extension.hs4
-rw-r--r--compiler/Language/Haskell/Syntax/Pat.hs32
-rw-r--r--compiler/Language/Haskell/Syntax/Pat.hs-boot3
4 files changed, 38 insertions, 3 deletions
diff --git a/compiler/Language/Haskell/Syntax/Expr.hs b/compiler/Language/Haskell/Syntax/Expr.hs
index b472ac9589..c7c22c2bc1 100644
--- a/compiler/Language/Haskell/Syntax/Expr.hs
+++ b/compiler/Language/Haskell/Syntax/Expr.hs
@@ -1065,7 +1065,7 @@ data Match p body
m_ext :: XCMatch p body,
m_ctxt :: HsMatchContext p,
-- See note [m_ctxt in Match]
- m_pats :: [LPat p], -- The patterns
+ m_pats :: [LMatchPat p], -- The patterns
m_grhss :: (GRHSs p body)
}
| XMatch !(XXMatch p body)
diff --git a/compiler/Language/Haskell/Syntax/Extension.hs b/compiler/Language/Haskell/Syntax/Extension.hs
index 8d8eadf135..fa7628f8ad 100644
--- a/compiler/Language/Haskell/Syntax/Extension.hs
+++ b/compiler/Language/Haskell/Syntax/Extension.hs
@@ -583,6 +583,10 @@ type family XSigPat x
type family XCoPat x
type family XXPat x
type family XHsFieldBind x
+type family XVisPat x
+type family XInvisTyVarPat x
+type family XInvisWildTyPat x
+type family XXMatchPat x
-- =====================================================================
-- Type families for the HsTypes type families
diff --git a/compiler/Language/Haskell/Syntax/Pat.hs b/compiler/Language/Haskell/Syntax/Pat.hs
index 4393ad998a..02948d9664 100644
--- a/compiler/Language/Haskell/Syntax/Pat.hs
+++ b/compiler/Language/Haskell/Syntax/Pat.hs
@@ -19,8 +19,7 @@
-- See Note [Language.Haskell.Syntax.* Hierarchy] for why not GHC.Hs.*
module Language.Haskell.Syntax.Pat (
- Pat(..), LPat,
- ConLikeP,
+ Pat(..), LPat, MatchPat(..), LMatchPat, toLPats, toPats, toInvisPats, ConLikeP,
HsConPatDetails, hsConPatArgs,
HsRecFields(..), HsFieldBind(..), LHsFieldBind,
@@ -214,6 +213,35 @@ data Pat p
type family ConLikeP x
+data MatchPat pass
+ = VisPat (XVisPat pass) (LPat pass)
+ | InvisTyVarPat (XInvisTyVarPat pass) (LIdP pass)
+ | InvisWildTyPat (XInvisWildTyPat pass)
+ | XMatchPat !(XXMatchPat pass)
+
+type LMatchPat pass = XRec pass (MatchPat pass)
+
+toLPats :: forall pass. UnXRec pass => [LMatchPat pass] -> [LPat pass]
+toLPats [] = []
+toLPats (x : xs) =
+ case unXRec @pass x of
+ VisPat _ pat -> pat : toLPats xs
+ _ -> toLPats xs
+
+toPats :: forall pass. UnXRec pass => [MatchPat pass] -> [Pat pass]
+toPats [] = []
+toPats (x : xs) =
+ case x of
+ VisPat _ pat -> unXRec @pass pat : toPats xs
+ _ -> toPats xs
+
+toInvisPats :: forall pass. UnXRec pass => [LMatchPat pass] -> [LMatchPat pass]
+toInvisPats [] = []
+toInvisPats (x : xs) =
+ case unXRec @pass x of
+ InvisTyVarPat _ _ -> x : toInvisPats xs
+ InvisWildTyPat _ -> x : toInvisPats xs
+ _ -> toInvisPats xs
-- ---------------------------------------------------------------------
diff --git a/compiler/Language/Haskell/Syntax/Pat.hs-boot b/compiler/Language/Haskell/Syntax/Pat.hs-boot
index 4ff0371e39..29ec86565f 100644
--- a/compiler/Language/Haskell/Syntax/Pat.hs-boot
+++ b/compiler/Language/Haskell/Syntax/Pat.hs-boot
@@ -9,5 +9,8 @@ import Language.Haskell.Syntax.Extension ( XRec )
import Data.Kind
type role Pat nominal
+type role MatchPat nominal
data Pat (i :: Type)
type LPat i = XRec i (Pat i)
+data MatchPat i
+type LMatchPat i = XRec i (MatchPat i)