Skip to content

stack haddock groups modules incorrectly #6864

@nicuveo

Description

@nicuveo

Overview

When running stack haddock in a project, the generated documentation groups documentation modules in an unpredictable way.

Steps to reproduce

Create a trivial project with a few dependencies, like so:

# stack.yaml
snapshot:
  url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/24/34.yaml
packages:
  - .

# package.yaml
dependencies:
  - base
  - storable-record

library:
  source-dirs: lib

Then run stack haddock. Then open the documentation at file:///<project>/.stack-work/install/<platform>/<hash>/<ghc>/doc/all/index.html.

In it, modules are not grouped in a way that makes sense. For instance:

  • all base modules are grouped under QuickCheck-2.15.0.1;
  • all transformers modules are grouped under semigroups-0.20.1;
  • all mtl modules are at the top level, not within a package group.

A call to $ stack haddock --verbose reveals that documentation is created with the following haddock call:

/$HOME/.ghcup/ghc/9.10.3/bin/haddock-ghc-9.10.3 \
  --optghc=-package-db=/$HOME/.stack/snapshots/x86_64-linux/8a23ab0f4c447aa1863c20e527e4f2aeeec2f0c3c2ab9fbe859c65d4c711ecc7/9.10.3/pkgdb \
  --optghc=-package-db=/$HOME/$PROJECT/.stack-work/install/x86_64-linux/8a23ab0f4c447aa1863c20e527e4f2aeeec2f0c3c2ab9fbe859c65d4c711ecc7/9.10.3/pkgdb \
  --gen-contents \
  --gen-index \
  -i ../ghc-boot-th-9.10.3-9679,/$HOME/.ghcup/ghc/9.10.3/lib/ghc-9.10.3/lib/../../../share/doc/ghc-9.10.3/html/libraries/ghc-boot-th-9.10.3-9679/ghc-boot-th.haddock \
  -i ../mtl-2.3.1-bcd6,/$HOME/.ghcup/ghc/9.10.3/lib/ghc-9.10.3/lib/../../../share/doc/ghc-9.10.3/html/libraries/mtl-2.3.1-bcd6/mtl.haddock \
  -i ../array-0.5.8.0-4471,/$HOME/.ghcup/ghc/9.10.3/lib/ghc-9.10.3/lib/../../../share/doc/ghc-9.10.3/html/libraries/array-0.5.8.0-4471/array.haddock \
  -i ../ghc-internal-9.1003.0-a65c,/$HOME/.ghcup/ghc/9.10.3/lib/ghc-9.10.3/lib/../../../share/doc/ghc-9.10.3/html/libraries/ghc-internal-9.1003.0-a65c/ghc-internal.haddock \
  -i ../storable-record-0.0.7,/$HOME/.stack/snapshots/x86_64-linux/03a149f03ae9045878c23602050e9feb226fcf703f9493ca6662ad2a61705976/9.10.3/doc/storable-record-0.0.7/storable-record.haddock \
  -i ../utility-ht-0.0.17.2,/$HOME/.stack/snapshots/x86_64-linux/03a149f03ae9045878c23602050e9feb226fcf703f9493ca6662ad2a61705976/9.10.3/doc/utility-ht-0.0.17.2/utility-ht.haddock \
  -i ../containers-0.7-bf99,/$HOME/.ghcup/ghc/9.10.3/lib/ghc-9.10.3/lib/../../../share/doc/ghc-9.10.3/html/libraries/containers-0.7-bf99/containers.haddock \
  -i ../splitmix-0.1.3.2,/$HOME/.stack/snapshots/x86_64-linux/03a149f03ae9045878c23602050e9feb226fcf703f9493ca6662ad2a61705976/9.10.3/doc/splitmix-0.1.3.2/splitmix.haddock \
  -i ../pretty-1.1.3.6-7ead,/$HOME/.ghcup/ghc/9.10.3/lib/ghc-9.10.3/lib/../../../share/doc/ghc-9.10.3/html/libraries/pretty-1.1.3.6-7ead/pretty.haddock \
  -i ../haddock-issue-0.0.0,/$HOME/$PROJECT/.stack-work/install/x86_64-linux/8a23ab0f4c447aa1863c20e527e4f2aeeec2f0c3c2ab9fbe859c65d4c711ecc7/9.10.3/doc/haddock-issue-0.0.0/haddock-issue.haddock \
  -i ../deepseq-1.5.0.0-268d,/$HOME/.ghcup/ghc/9.10.3/lib/ghc-9.10.3/lib/../../../share/doc/ghc-9.10.3/html/libraries/deepseq-1.5.0.0-268d/deepseq.haddock \
  -i ../template-haskell-2.22.0.0-5e01,/$HOME/.ghcup/ghc/9.10.3/lib/ghc-9.10.3/lib/../../../share/doc/ghc-9.10.3/html/libraries/template-haskell-2.22.0.0-5e01/template-haskell.haddock \
  -i ../random-1.2.1.3,/$HOME/.stack/snapshots/x86_64-linux/03a149f03ae9045878c23602050e9feb226fcf703f9493ca6662ad2a61705976/9.10.3/doc/random-1.2.1.3/random.haddock \
  -i ../ghc-bignum-1.3-9ca9,/$HOME/.ghcup/ghc/9.10.3/lib/ghc-9.10.3/lib/../../../share/doc/ghc-9.10.3/html/libraries/ghc-bignum-1.3-9ca9/ghc-bignum.haddock \
  -i ../QuickCheck-2.15.0.1,/$HOME/.stack/snapshots/x86_64-linux/03a149f03ae9045878c23602050e9feb226fcf703f9493ca6662ad2a61705976/9.10.3/doc/QuickCheck-2.15.0.1/QuickCheck.haddock \
  -i ../base-4.20.2.0-127e,/$HOME/.ghcup/ghc/9.10.3/lib/ghc-9.10.3/lib/../../../share/doc/ghc-9.10.3/html/libraries/base-4.20.2.0-127e/base.haddock \
  -i ../bytestring-0.12.2.0-825f,/$HOME/.ghcup/ghc/9.10.3/lib/ghc-9.10.3/lib/../../../share/doc/ghc-9.10.3/html/libraries/bytestring-0.12.2.0-825f/bytestring.haddock \
  -i ../semigroups-0.20.1,/$HOME/.stack/snapshots/x86_64-linux/03a149f03ae9045878c23602050e9feb226fcf703f9493ca6662ad2a61705976/9.10.3/doc/semigroups-0.20.1/semigroups.haddock \
  -i ../transformers-0.6.1.1-4229,/$HOME/.ghcup/ghc/9.10.3/lib/ghc-9.10.3/lib/../../../share/doc/ghc-9.10.3/html/libraries/transformers-0.6.1.1-4229/transformers.haddock \
  -i ../ghc-prim-0.12.0-d0f9,/$HOME/.ghcup/ghc/9.10.3/lib/ghc-9.10.3/lib/../../../share/doc/ghc-9.10.3/html/libraries/ghc-prim-0.12.0-d0f9/ghc-prim.haddock

I have tried running the same command without the package-db arguments, and it removes all grouping, which suggests that the issue stems from an incorrect grouping in the pkgdb files?

Stack version

$ stack --version
Version 3.9.3, Git revision c7eb8487a82d5c3e0b88d56f8b8a98be23223eb5 x86_64 hpack-0.39.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions