haskell / haddock

Haskell Documentation Tool
www.haskell.org/haddock/
BSD 2-Clause "Simplified" License
361 stars 242 forks source link

Ambigious associated type links to its associated class #1615

Closed jorisdral closed 1 month ago

jorisdral commented 8 months ago

I found that a hyperlink to an associated type links to its class instead of the associated type if the type name is ambiguous. I noticed this when I was looking at the documentation of generics-sop. In particular, I saw that Generic is rendered in the docs for deriveGeneric instead of Code. Code is an associated type of the class Generic, and Code is ambiguous (the name is defined in a TH module as well).

image

-- | Generate @generics-sop@ boilerplate for the given datatype.
--
-- This function takes the name of a datatype and generates:
--
--   * a 'Code' instance
--   * a 'Generic' instance
--   * a 'HasDatatypeInfo' instance
{- remainder elided -}
deriveGeneric :: Name -> Q [Dec]

The following is a minimal example. I was able to reproduce the bug with that example on ghc-9.2.8, ghc-9.4.7, and ghc-9.6.3, but it's not a problem on ghc-8.10.7.

Minimal example ```haskell module A where data T ``` ```haskell {-# LANGUAGE TypeFamilies #-} module B where class B where type T ```` ```haskell module Main where import A import B -- | 'T' should be rendered as @T@ main :: IO () main = pure () ```
jorisdral commented 8 months ago

Might be related to https://github.com/haskell/haddock/issues/1608?

Kleidukos commented 1 month ago

Hi, thank you for this ticket, but Haddock now lives full-time in the GHC repository! Read more at https://discourse.haskell.org/t/haddock-now-lives-in-the-ghc-repository/9576.

Let me know if you feel it is still needed, and I'll migrate it. :)