haddock icon indicating copy to clipboard operation
haddock copied to clipboard

Ambigious associated type links to its associated class

Open jorisdral opened this issue 2 years ago • 1 comments

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
module A where
data T
{-# LANGUAGE TypeFamilies #-}
module B where
class B where
  type T
module Main where
import A
import B
-- | 'T' should be rendered as @T@
main :: IO ()
main = pure ()

jorisdral avatar Oct 17 '23 16:10 jorisdral

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

jorisdral avatar Oct 17 '23 16:10 jorisdral

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. :)

Kleidukos avatar May 18 '24 15:05 Kleidukos