Skip to content
This repository was archived by the owner on Aug 3, 2024. It is now read-only.

Commit a650450

Browse files
authored
Print kinded tyvars in constructors for Hoogle (#993)
Fixes #992
1 parent 39251d3 commit a650450

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

haddock-api/src/Haddock/Backends/Hoogle.hs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,14 @@ ppCtor dflags dat subdocs con@ConDeclH98 {}
266266
-- docs for con_names on why it is a list to begin with.
267267
name = commaSeparate dflags . map unL $ getConNames con
268268

269-
resType = apps $ map (reL . HsTyVar NoExt NotPromoted . reL) $
270-
(tcdName dat) : [hsTyVarName v | L _ v@(UserTyVar _ _) <- hsQTvExplicit $ tyClDeclTyVars dat]
269+
resType = let c = HsTyVar NoExt NotPromoted (noLoc (tcdName dat))
270+
as = map (tyVarBndr2Type . unLoc) (hsQTvExplicit $ tyClDeclTyVars dat)
271+
in apps (map noLoc (c : as))
272+
273+
tyVarBndr2Type :: HsTyVarBndr GhcRn -> HsType GhcRn
274+
tyVarBndr2Type (UserTyVar _ n) = HsTyVar NoExt NotPromoted n
275+
tyVarBndr2Type (KindedTyVar _ n k) = HsKindSig NoExt (noLoc (HsTyVar NoExt NotPromoted n)) k
276+
tyVarBndr2Type (XTyVarBndr _) = panic "haddock:ppCtor"
271277

272278
ppCtor dflags _dat subdocs con@(ConDeclGADT { })
273279
= concatMap (lookupCon dflags subdocs) (getConNames con) ++ f

hoogle-test/ref/Bug992/test.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
-- Hoogle documentation, generated by Haddock
2+
-- See Hoogle, http://www.haskell.org/hoogle/
3+
4+
@package test
5+
@version 0.0.0
6+
7+
module Bug992
8+
data K (m :: * -> *)
9+
K :: K (m :: * -> *)

hoogle-test/src/Bug992/Bug992.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{-# LANGUAGE KindSignatures #-}
2+
3+
module Bug992 where
4+
5+
data K (m :: * -> *) = K

0 commit comments

Comments
 (0)