From b21c806740fd41e3fd25e17edc412aa69825611d Mon Sep 17 00:00:00 2001 From: Alec Theriault Date: Tue, 16 Oct 2018 17:42:05 -0700 Subject: Output pattern synonyms in Hoogle backend (#947) * Output pattern synonyms in Hoogle backend We were previously weren't outputting _any_ pattern synonyms, bundled or not. Now, we output both. Fixes #946. * Update changelog --- haddock-api/src/Haddock/Backends/Hoogle.hs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'haddock-api/src/Haddock/Backends/Hoogle.hs') diff --git a/haddock-api/src/Haddock/Backends/Hoogle.hs b/haddock-api/src/Haddock/Backends/Hoogle.hs index 885c608b..5f77c38c 100644 --- a/haddock-api/src/Haddock/Backends/Hoogle.hs +++ b/haddock-api/src/Haddock/Backends/Hoogle.hs @@ -122,10 +122,14 @@ commaSeparate dflags = showSDocUnqual dflags . interpp'SP ppExport :: DynFlags -> ExportItem GhcRn -> [String] ppExport dflags ExportDecl { expItemDecl = L _ decl - , expItemMbDoc = (dc, _) + , expItemPats = bundledPats + , expItemMbDoc = mbDoc , expItemSubDocs = subdocs , expItemFixities = fixities - } = ppDocumentation dflags dc ++ f decl ++ ppFixities + } = concat [ ppDocumentation dflags dc ++ f d + | (d, (dc, _)) <- (decl, mbDoc) : bundledPats + ] ++ + ppFixities where f (TyClD _ d@DataDecl{}) = ppData dflags d subdocs f (TyClD _ d@SynDecl{}) = ppSynonym dflags d @@ -140,12 +144,13 @@ ppExport dflags ExportDecl { expItemDecl = L _ decl ppExport _ _ = [] ppSigWithDoc :: DynFlags -> Sig GhcRn -> [(Name, DocForDecl Name)] -> [String] -ppSigWithDoc dflags (TypeSig _ names sig) subdocs - = concatMap mkDocSig names - where - mkDocSig n = mkSubdoc dflags n subdocs [pp_sig dflags [n] (hsSigWcType sig)] - -ppSigWithDoc _ _ _ = [] +ppSigWithDoc dflags sig subdocs = case sig of + TypeSig _ names t -> concatMap (mkDocSig "" (hsSigWcType t)) names + PatSynSig _ names t -> concatMap (mkDocSig "pattern " (hsSigType t)) names + _ -> [] + where + mkDocSig leader typ n = mkSubdoc dflags n subdocs + [leader ++ pp_sig dflags [n] typ] ppSig :: DynFlags -> Sig GhcRn -> [String] ppSig dflags x = ppSigWithDoc dflags x [] -- cgit v1.2.3