@@ -38,7 +38,7 @@ destructMatches f f2 t jdg = do
38
38
case dcs of
39
39
[] -> throwError $ GoalMismatch " destruct" g
40
40
_ -> for dcs $ \ dc -> do
41
- let args = dataConInstOrigArgTys dc apps
41
+ let args = dataConInstOrigArgTys' dc apps
42
42
names <- mkManyGoodNames hy args
43
43
44
44
let pat :: Pat GhcPs
@@ -51,9 +51,19 @@ destructMatches f f2 t jdg = do
51
51
pure $ match [pat] $ unLoc sg
52
52
53
53
54
+ -- | Essentially same as 'dataConInstOrigArgTys' in GHC,
55
+ -- but we need some tweaks in GHC >= 8.8.
56
+ -- Since old 'dataConInstArgTys' seems working with >= 8.8,
57
+ -- we just filter out non-class types in the result.
58
+ dataConInstOrigArgTys' :: DataCon -> [Type ] -> [Type ]
59
+ dataConInstOrigArgTys' con ty =
60
+ let tys0 = dataConInstArgTys con ty
61
+ in filter (maybe True (not . isClassTyCon) . tyConAppTyCon_maybe) tys0
62
+
54
63
------------------------------------------------------------------------------
55
64
-- | Combinator for performing case splitting, and running sub-rules on the
56
65
-- resulting matches.
66
+
57
67
destruct' :: (DataCon -> Judgement -> Rule ) -> OccName -> Judgement -> Rule
58
68
destruct' f term jdg = do
59
69
let hy = jHypothesis jdg
@@ -85,7 +95,7 @@ buildDataCon
85
95
-> [Type ] -- ^ Type arguments for the data con
86
96
-> RuleM (LHsExpr GhcPs )
87
97
buildDataCon jdg dc apps = do
88
- let args = dataConInstOrigArgTys dc apps
98
+ let args = dataConInstOrigArgTys' dc apps
89
99
sgs <- traverse (newSubgoal . flip withNewGoal jdg . CType ) args
90
100
pure
91
101
. noLoc
0 commit comments