Skip to content

Commit 96bd4c9

Browse files
committed
Proper treatment of existentially quantified type variables in DataCons
1 parent 4ad648e commit 96bd4c9

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

plugins/tactics/src/Ide/Plugin/Tactic/CodeGen.hs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import GHC.SourceGen.Binds
2323
import GHC.SourceGen.Expr
2424
import GHC.SourceGen.Overloaded
2525
import GHC.SourceGen.Pat
26+
import Ide.Plugin.Tactic.GHC
2627
import Ide.Plugin.Tactic.Judgements
2728
import Ide.Plugin.Tactic.Machinery
2829
import Ide.Plugin.Tactic.Naming
@@ -120,13 +121,13 @@ unzipTrace l =
120121

121122

122123
-- | Essentially same as 'dataConInstOrigArgTys' in GHC,
123-
-- but we need some tweaks in GHC >= 8.8.
124-
-- Since old 'dataConInstArgTys' seems working with >= 8.8,
125-
-- we just filter out class dictionaries and coercions from the result.
124+
-- but only accepts universally quantified types as the second arguments
125+
-- and automatically introduces existentials.
126126
dataConInstOrigArgTys' :: DataCon -> [Type] -> [Type]
127-
dataConInstOrigArgTys' con ty =
128-
let tys0 = dataConInstOrigArgTys con ty
129-
in filter (not . isPredTy) tys0
127+
dataConInstOrigArgTys' con uniTys =
128+
let exvars = dataConExTys con
129+
in dataConInstOrigArgTys con $
130+
uniTys ++ map mkTyVarTy exvars
130131

131132
------------------------------------------------------------------------------
132133
-- | Combinator for performing case splitting, and running sub-rules on the

0 commit comments

Comments
 (0)