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

Commit bc962c9

Browse files
committed
1 parent 39996e2 commit bc962c9

File tree

5 files changed

+32
-6
lines changed

5 files changed

+32
-6
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ declNames :: LHsDecl DocNameI
255255
, [DocName] -- names being declared
256256
)
257257
declNames (L _ decl) = case decl of
258-
TyClD _ d -> (empty, [tcdName d])
258+
TyClD _ d -> (empty, [tcdNameI d])
259259
SigD _ (TypeSig _ lnames _ ) -> (empty, map unLoc lnames)
260260
SigD _ (PatSynSig _ lnames _) -> (text "pattern", map unLoc lnames)
261261
ForD _ (ForeignImport _ (L _ n) _ _) -> (empty, [n])

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ ppJsonIndex odir maybe_source_url maybe_wiki_url unicode pkg qual_opt ifaces = d
407407
exportSubs _ = []
408408

409409
exportName :: ExportItem DocNameI -> [IdP DocNameI]
410-
exportName ExportDecl { expItemDecl } = getMainDeclBinder (unLoc expItemDecl)
410+
exportName ExportDecl { expItemDecl } = getMainDeclBinderI (unLoc expItemDecl)
411411
exportName ExportNoDecl { expItemName } = [expItemName]
412412
exportName _ = []
413413

haddock-api/src/Haddock/Backends/Xhtml/Decl.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,8 @@ ppClassDecl summary links instances fixities loc d subdocs
536536
-- Only the fixity relevant to the class header
537537
fixs = ppFixities [ f | f@(n,_) <- fixities, n == unLoc lname ] qual
538538

539+
nm = tcdNameI decl
540+
539541
hdr = ppClassHdr summary lctxt (unLoc lname) ltyvars lfds
540542

541543
-- Associated types
@@ -794,7 +796,7 @@ ppDataDecl summary links instances fixities subdocs loc doc dataDecl pats
794796
| otherwise = header_ +++ docSection curname pkg qual doc +++ constrBit +++ patternBit +++ instancesBit
795797

796798
where
797-
docname = tcdName dataDecl
799+
docname = tcdNameI dataDecl
798800
curname = Just $ getName docname
799801
cons = dd_cons (tcdDataDefn dataDecl)
800802
isH98 = case unLoc (head cons) of

haddock-api/src/Haddock/GhcUtils.hs

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ moduleString = moduleNameString . moduleName
5858
isNameSym :: Name -> Bool
5959
isNameSym = isSymOcc . nameOccName
6060

61-
getMainDeclBinder :: (SrcSpanLess (LPat p) ~ Pat p , HasSrcSpan (LPat p)) =>
62-
HsDecl p -> [IdP p]
61+
getMainDeclBinder :: HsDecl (GhcPass p) -> [IdP (GhcPass p)]
6362
getMainDeclBinder (TyClD _ d) = [tcdName d]
6463
getMainDeclBinder (ValD _ d) =
6564
case collectHsBindBinders d of
@@ -221,6 +220,31 @@ getGADTConType (ConDeclH98 {}) = panic "getGADTConType"
221220
-- Should only be called on ConDeclGADT
222221
getGADTConType (XConDecl nec) = noExtCon nec
223222

223+
getMainDeclBinderI :: HsDecl DocNameI -> [IdP DocNameI]
224+
getMainDeclBinderI (TyClD _ d) = [tcdNameI d]
225+
getMainDeclBinderI (ValD _ d) =
226+
case collectHsBindBinders d of
227+
[] -> []
228+
(name:_) -> [name]
229+
getMainDeclBinderI (SigD _ d) = sigNameNoLoc d
230+
getMainDeclBinderI (ForD _ (ForeignImport _ name _ _)) = [unLoc name]
231+
getMainDeclBinderI (ForD _ (ForeignExport _ _ _ _)) = []
232+
getMainDeclBinderI _ = []
233+
234+
familyDeclLNameI :: FamilyDecl DocNameI -> Located DocName
235+
familyDeclLNameI (FamilyDecl { fdLName = n }) = n
236+
familyDeclLNameI (XFamilyDecl nec) = noExtCon nec
237+
238+
tyClDeclLNameI :: TyClDecl DocNameI -> Located DocName
239+
tyClDeclLNameI (FamDecl { tcdFam = fd }) = familyDeclLNameI fd
240+
tyClDeclLNameI (SynDecl { tcdLName = ln }) = ln
241+
tyClDeclLNameI (DataDecl { tcdLName = ln }) = ln
242+
tyClDeclLNameI (ClassDecl { tcdLName = ln }) = ln
243+
tyClDeclLNameI (XTyClDecl nec) = noExtCon nec
244+
245+
tcdNameI :: TyClDecl DocNameI -> DocName
246+
tcdNameI = unLoc . tyClDeclLNameI
247+
224248
-- -------------------------------------
225249

226250
getGADTConTypeG :: ConDecl (GhcPass p) -> LHsType (GhcPass p)
@@ -761,4 +785,3 @@ defaultRuntimeRepVars = go emptyVarEnv
761785

762786
go _ ty@(LitTy {}) = ty
763787
go _ ty@(CoercionTy {}) = ty
764-

haddock-api/src/Haddock/Types.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,7 @@ type instance XDataDecl DocNameI = NoExtField
789789
type instance XSynDecl DocNameI = NoExtField
790790
type instance XFamDecl DocNameI = NoExtField
791791
type instance XXFamilyDecl DocNameI = NoExtCon
792+
type instance XXTyClDecl DocNameI = NoExtCon
792793

793794
type instance XHsIB DocNameI _ = NoExtField
794795
type instance XHsWC DocNameI _ = NoExtField

0 commit comments

Comments
 (0)