generateDepsHaddockIndex
    :: (MonadIO m, MonadCatch m, MonadThrow m, MonadLogger m, MonadBaseControl IO m)
    => EnvOverride -> WhichCompiler -> BaseConfigOpts -> [LocalPackage] -> m ()
generateDepsHaddockIndex envOverride wc bco locals = do
    depSets <-
        mapM
            (\LocalPackage{lpPackage = Package{..}} ->
                  findTransitiveGhcPkgDepends
                      envOverride
                      wc
                      [bcoSnapDB bco, bcoLocalDB bco]
                      (PackageIdentifier packageName packageVersion))
            locals
    generateHaddockIndex
        "local packages and dependencies"
        envOverride
        wc
        (Set.toList (Set.unions depSets))
        ".."
        (localDocDir bco </> $(mkRelDir "all"))

-- | Generate Haddock index and contents for all snapshot packages.
generateDepsHaddockIndex
    :: (MonadIO m, MonadCatch m, MonadThrow m, MonadLogger m, MonadBaseControl IO m)
    => EnvOverride -> WhichCompiler -> BaseConfigOpts -> [LocalPackage] -> m ()
generateDepsHaddockIndex envOverride wc bco locals = do
    depSets <-
        mapM
            (\LocalPackage{lpPackage = Package{..}} ->
                  findTransitiveGhcPkgDepends
                      envOverride
                      wc
                      [bcoSnapDB bco, bcoLocalDB bco]
                      (PackageIdentifier packageName packageVersion))
            locals
    generateHaddockIndex
        "local packages and dependencies"
        envOverride
        wc
        (Set.toList (Set.unions depSets))
        ".."
        (localDocDir bco </> $(mkRelDir "all"))

-- | Generate Haddock index and contents for all snapshot packages.
generateDepsHaddockIndex envOverride wc bco locals = do
    depSets <-
        mapM
            (\LocalPackage{lpPackage = Package{..}} ->
                  findTransitiveGhcPkgDepends
                      envOverride
                      wc
                      [bcoSnapDB bco, bcoLocalDB bco]
                      (PackageIdentifier packageName packageVersion))
            locals
    generateHaddockIndex
        "local packages and dependencies"
        envOverride
        wc
        (Set.toList (Set.unions depSets))
        ".."
        (localDocDir bco </> $(mkRelDir "all"))

-- | Generate Haddock index and contents for all snapshot packages.