@@ -123,11 +123,28 @@ unzipTrace l =
123
123
-- | Essentially same as 'dataConInstOrigArgTys' in GHC,
124
124
-- but only accepts universally quantified types as the second arguments
125
125
-- and automatically introduces existentials.
126
- dataConInstOrigArgTys' :: DataCon -> [Type ] -> [Type ]
126
+ --
127
+ -- NOTE: The behaviour depends on GHC's 'dataConInstOrigArgTys'.
128
+ -- We need some tweaks if the compiler changes the implementation.
129
+ dataConInstOrigArgTys'
130
+ :: DataCon
131
+ -- ^ 'DataCon'structor
132
+ -> [Type ]
133
+ -- ^ /Universally/ quantified type arguments to a result type.
134
+ -- It /MUST NOT/ contain any dictionaries, coercion and existentials.
135
+ --
136
+ -- For example, for @MkMyGADT :: b -> MyGADT a c@, we
137
+ -- must pass @[a, c]@ as this argument but not @b@, as @b@ is an existential.
138
+ -> [Type ]
139
+ -- ^ Types of arguments to the DataCon with returned type is instantiated with the second argument.
127
140
dataConInstOrigArgTys' con uniTys =
128
141
let exvars = dataConExTys con
129
142
in dataConInstOrigArgTys con $
130
143
uniTys ++ fmap mkTyVarTy exvars
144
+ -- Rationale: At least in GHC <= 8.10, 'dataConInstOrigArgTys'
145
+ -- unifies the second argument with DataCon's universals followed by existentials.
146
+ -- If the definition of 'dataConInstOrigArgTys' changes,
147
+ -- this place must be changed accordingly.
131
148
132
149
------------------------------------------------------------------------------
133
150
-- | Combinator for performing case splitting, and running sub-rules on the
0 commit comments