[SOLVED] Hyperlinking to other packages when using Haddock locally

When I generate documentation for my package (using cabal v2-haddock), identifiers are only hyperlinked if they are within the same package. Identifiers in base (or other packages I depend on) are not hyperlinked.

And, indeed, Haddock complains about this when I run it:

could not find link destinations for:
    Bounded minBound maxBound Enum succ pred toEnum Int fromEnum
    enumFrom enumFromThen enumFromTo enumFromThenTo Eq == Bool /= Ord
    compare Ordering < <= > >= max min Read readsPrec ReadS readList
    readPrec ReadPrec readListPrec Show showsPrec ShowS show String
    showList Generic from Rep to Type NFData rnf Hashable hashWithSalt
    hash D1 MetaData False :+: C1 MetaCons PrefixI U1 Default def True
    :*: S1 MetaSel Just NoSourceUnpackedness SourceStrict
    DecidedStrict Rec0 HasCallStack Text Maybe Either Nothing

However, when I look at documentation on Hackage, all of the identifiers are hyperlinked, pointing to other packages when necessary.

How can I get my local Haddock documentation to link to the documentation on Hackage, for packages which come from Hackage?

Thanks!

Note: I’m currently using cabal-install version 2.4.0.0 and Haddock version 2.22.0 on Ubuntu 20.04.6, if it matters.

Does cabal haddock --enable-documentation work?

I tried cabal v2-haddock --enable-documentation, and it spent a long time building the docs for all the packages I depend on. So it was looking really good, but…

When building the docs for my package, it still gave the same could not find link destinations error messages as before, and the generated HTML still did not link any identifiers that were outside my package. :slightly_frowning_face:

Then I suggest you update Cabal and Haddock to more up-to-date versions; the easiest way is to use ghcup. Cabal 2.4 is really obsolete.

I ended up just using stack haddock instead, and that hyperlinked all the dependencies.

--haddock-for-hackage on a sufficiently new cabal should do the trick.

1 Like