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

Commit

Permalink
Fix issue with duplicate reexported definitions (T23616)
Browse files Browse the repository at this point in the history
When a class method was reexported, it's default methods were also
showing up in the generated html page.

The simplest and most non-invasive fix is to not look for the default
method if we are just exporting the class method.. because the backends
are just showing default methods when the whole class is exported.

In general it would be worthwhile to rewrite this bit of code I think as
the logic and what gets included is split over `lookupDocs` and
`availExportDecl` it would be clearer to combine the two. The result of
lookupDocs is always just passed to availExportDecl so it seems simpler
and more obvious to just write the function directly.
  • Loading branch information
mpickering authored and sheaf committed Sep 1, 2023
1 parent 5877bce commit 3949204
Show file tree
Hide file tree
Showing 3 changed files with 143 additions and 1 deletion.
3 changes: 2 additions & 1 deletion haddock-api/src/Haddock/Interface/Create.hs
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,8 @@ lookupDocs avail warningMap docMap argMap def_meths_env =
def_meths = [ (meth, (lookupDoc meth, lookupArgDoc meth))
| s <- subs
, let dmOcc = mkDefaultMethodOcc (nameOccName s)
, Just meth <- [lookupOccEnv def_meths_env dmOcc]]
, Just meth <- [lookupOccEnv def_meths_env dmOcc]
, availExportsDecl avail ]
subDocs = [ (s, (lookupDoc s, lookupArgDoc s))
| s <- subs
] ++ def_meths
Expand Down
138 changes: 138 additions & 0 deletions html-test/ref/T23616.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
<html xmlns="http://www.w3.org/1999/xhtml"
><head
><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
/><meta name="viewport" content="width=device-width, initial-scale=1"
/><title
>T23616</title
><link href="#" rel="stylesheet" type="text/css" title="Linuwial"
/><link rel="stylesheet" type="text/css" href="#"
/><link rel="stylesheet" type="text/css" href="#"
/><script src="haddock-bundle.min.js" async="async" type="text/javascript"
></script
><script type="text/x-mathjax-config"
>MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script
><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"
></script
></head
><body
><div id="package-header"
><span class="caption empty"
>&nbsp;</span
><ul class="links" id="page-menu"
><li
><a href="#"
>Contents</a
></li
><li
><a href="#"
>Index</a
></li
></ul
></div
><div id="content"
><div id="module-header"
><table class="info"
><tr
><th
>Safe Haskell</th
><td
>None</td
></tr
></table
><p class="caption"
>T23616</p
></div
><div id="synopsis"
><details id="syn"
><summary
>Synopsis</summary
><ul class="details-toggle" data-details-id="syn"
><li class="src short"
><a href="#"
>null</a
> :: <a href="#" title="Data.Foldable"
>Foldable</a
> t =&gt; t a -&gt; <a href="#" title="Data.Bool"
>Bool</a
></li
></ul
></details
></div
><div id="interface"
><h1
>Documentation</h1
><div class="top"
><p class="src"
><a id="v:null" class="def"
>null</a
> :: <a href="#" title="Data.Foldable"
>Foldable</a
> t =&gt; t a -&gt; <a href="#" title="Data.Bool"
>Bool</a
> <a href="#" class="selflink"
>#</a
></p
><div class="doc"
><p
>Test whether the structure is empty. The default implementation is
Left-associative and lazy in both the initial element and the
accumulator. Thus optimised for structures where the first element can
be accessed in constant time. Structures where this is not the case
should have a non-default implementation.</p
><h4 class="subheading details-toggle-control details-toggle" data-details-id="ch:null0"
>Examples</h4
><details id="ch:null0"
><summary class="hide-when-js-enabled"
>Expand</summary
><p
>Basic usage:</p
><pre class="screen"
><code class="prompt"
>&gt;&gt;&gt; </code
><strong class="userinput"
><code
>null []
</code
></strong
>True
</pre
><pre class="screen"
><code class="prompt"
>&gt;&gt;&gt; </code
><strong class="userinput"
><code
>null [1]
</code
></strong
>False
</pre
><p
><code
><a href="#" title="GHC.List"
>null</a
></code
> is expected to terminate even for infinite structures.
The default implementation terminates provided the structure
is bounded on the left (there is a leftmost element).</p
><pre class="screen"
><code class="prompt"
>&gt;&gt;&gt; </code
><strong class="userinput"
><code
>null [1..]
</code
></strong
>False
</pre
></details
><p
><em
>Since: base-4.8.0.0</em
></p
></div
></div
></div
></div
></body
></html
>
3 changes: 3 additions & 0 deletions html-test/src/T23616.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module T23616 (null) where

import Data.Foldable

0 comments on commit 3949204

Please sign in to comment.