@@ -155,7 +155,7 @@ synifyTyCon _coax tc
155
155
-- algebraic data nor newtype:
156
156
, dd_ctxt = noLoc []
157
157
, dd_cType = Nothing
158
- , dd_kindSig = Just (synifyKindSig (tyConKind tc))
158
+ , dd_kindSig = synifyDataTyConReturnKind tc
159
159
-- we have their kind accurately:
160
160
, dd_cons = [] -- No constructors
161
161
, dd_derivs = noLoc [] }
@@ -210,7 +210,7 @@ synifyTyCon coax tc
210
210
-- CoAxioms, not their TyCons
211
211
_ -> synifyName tc
212
212
tyvars = synifyTyVars (tyConTyVars tc)
213
- kindSig = Just (tyConKind tc)
213
+ kindSig = synifyDataTyConReturnKind tc
214
214
-- The data constructors.
215
215
--
216
216
-- Any data-constructors not exported from the module that *defines* the
@@ -235,7 +235,7 @@ synifyTyCon coax tc
235
235
defn = HsDataDefn { dd_ND = alg_nd
236
236
, dd_ctxt = alg_ctx
237
237
, dd_cType = Nothing
238
- , dd_kindSig = fmap synifyKindSig kindSig
238
+ , dd_kindSig = kindSig
239
239
, dd_cons = cons
240
240
, dd_derivs = alg_deriv }
241
241
in case lefts consRaw of
@@ -245,6 +245,27 @@ synifyTyCon coax tc
245
245
, tcdDataCusk = False , tcdFVs = placeHolderNamesTc }
246
246
dataConErrs -> Left $ unlines dataConErrs
247
247
248
+ -- In this module, every TyCon being considered has come from an interface
249
+ -- file. This means that when considering a data type constructor such as:
250
+ --
251
+ -- data Foo (w :: *) (m :: * -> *) (a :: *)
252
+ --
253
+ -- Then its tyConKind will be (* -> (* -> *) -> * -> *). But beware! We are
254
+ -- also rendering the type variables of Foo, so if we synify the tyConKind of
255
+ -- Foo in full, we will end up displaying this in Haddock:
256
+ --
257
+ -- data Foo (w :: *) (m :: * -> *) (a :: *)
258
+ -- :: * -> (* -> *) -> * -> *
259
+ --
260
+ -- Which is entirely wrong (#548). We only want to display the *return* kind,
261
+ -- which this function obtains.
262
+ synifyDataTyConReturnKind :: TyCon -> Maybe (LHsKind Name )
263
+ synifyDataTyConReturnKind tc
264
+ = case splitFunTys (tyConKind tc) of
265
+ (_, ret_kind)
266
+ | isLiftedTypeKind ret_kind -> Nothing -- Don't bother displaying :: *
267
+ | otherwise -> Just (synifyKindSig ret_kind)
268
+
248
269
synifyInjectivityAnn :: Maybe Name -> [TyVar ] -> Injectivity
249
270
-> Maybe (LInjectivityAnn Name )
250
271
synifyInjectivityAnn Nothing _ _ = Nothing
0 commit comments