@@ -164,7 +164,7 @@ synifyTyCon _coax tc
164
164
-- algebraic data nor newtype:
165
165
, dd_ctxt = noLoc []
166
166
, dd_cType = Nothing
167
- , dd_kindSig = Just (synifyKindSig (tyConKind tc))
167
+ , dd_kindSig = synifyDataTyConReturnKind tc
168
168
-- we have their kind accurately:
169
169
, dd_cons = [] -- No constructors
170
170
, dd_derivs = noLoc [] }
@@ -219,7 +219,7 @@ synifyTyCon coax tc
219
219
-- CoAxioms, not their TyCons
220
220
_ -> synifyName tc
221
221
tyvars = synifyTyVars (tyConVisibleTyVars tc)
222
- kindSig = Just (tyConKind tc)
222
+ kindSig = synifyDataTyConReturnKind tc
223
223
-- The data constructors.
224
224
--
225
225
-- Any data-constructors not exported from the module that *defines* the
@@ -244,7 +244,7 @@ synifyTyCon coax tc
244
244
defn = HsDataDefn { dd_ND = alg_nd
245
245
, dd_ctxt = alg_ctx
246
246
, dd_cType = Nothing
247
- , dd_kindSig = fmap synifyKindSig kindSig
247
+ , dd_kindSig = kindSig
248
248
, dd_cons = cons
249
249
, dd_derivs = alg_deriv }
250
250
in case lefts consRaw of
@@ -254,6 +254,27 @@ synifyTyCon coax tc
254
254
, tcdDataCusk = False , tcdFVs = placeHolderNamesTc }
255
255
dataConErrs -> Left $ unlines dataConErrs
256
256
257
+ -- In this module, every TyCon being considered has come from an interface
258
+ -- file. This means that when considering a data type constructor such as:
259
+ --
260
+ -- data Foo (w :: *) (m :: * -> *) (a :: *)
261
+ --
262
+ -- Then its tyConKind will be (* -> (* -> *) -> * -> *). But beware! We are
263
+ -- also rendering the type variables of Foo, so if we synify the tyConKind of
264
+ -- Foo in full, we will end up displaying this in Haddock:
265
+ --
266
+ -- data Foo (w :: *) (m :: * -> *) (a :: *)
267
+ -- :: * -> (* -> *) -> * -> *
268
+ --
269
+ -- Which is entirely wrong (#548). We only want to display the *return* kind,
270
+ -- which this function obtains.
271
+ synifyDataTyConReturnKind :: TyCon -> Maybe (LHsKind Name )
272
+ synifyDataTyConReturnKind tc
273
+ = case splitFunTys (tyConKind tc) of
274
+ (_, ret_kind)
275
+ | isLiftedTypeKind ret_kind -> Nothing -- Don't bother displaying :: *
276
+ | otherwise -> Just (synifyKindSig ret_kind)
277
+
257
278
synifyInjectivityAnn :: Maybe Name -> [TyVar ] -> Injectivity
258
279
-> Maybe (LInjectivityAnn GhcRn )
259
280
synifyInjectivityAnn Nothing _ _ = Nothing
0 commit comments