Skip to content
Snippets Groups Projects
Unverified Commit b21c8067 authored by Alec Theriault's avatar Alec Theriault Committed by GitHub
Browse files

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
parent 99253fd7
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,8 @@
* Support type and data families in the LaTeX backend (#734)
* Support pattern synonyms in the Hoogle backend (#947)
## Changes in version 2.21.0
* Overhaul handling of data declarations in XHTML and LaTeX. Adds support for
......
......@@ -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 []
......
-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
@package test
@version 0.0.0
module Bug946
-- | A wrapper around <a>Int</a>
data AnInt
-- | some <a>Int</a>
AnInt :: Int -> AnInt
-- | The <a>Int</a> 0
pattern Zero :: AnInt
-- | The double 2.5
pattern TwoPointFive :: Double
{-# LANGUAGE PatternSynonyms #-}
module Bug946 (
AnInt(AnInt, Zero),
pattern TwoPointFive,
) where
-- | A wrapper around 'Int'
data AnInt = AnInt Int -- ^ some 'Int'
-- | The 'Int' 0
pattern Zero :: AnInt
pattern Zero = AnInt 0
-- | The double 2.5
pattern TwoPointFive :: Double
pattern TwoPointFive = 2.5
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment