haskell / haskell/cabal

GHC 9.4.2/Cabal 3.8.1.0 and PackageImports with reexported-modules - Problem

Open
#8,548 10 comments 0 reactions 0 assignees View on GitHub
blocked: ghc blocked: upstream status: consider closing
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

I am having problems with GHC 9.4.2/`Cabal-3.8.1.0` and `PackageImports` with Cabal's `reexported-modules`. I think what I am experiencing is a bug - I apologise if it is 'by design'. To explain:

I have a library in package `my-package-B` which exposes module `LibB`. I have a library in package `my-package-A` which `build-depends` on `my-package-B` and has `reexported-modules` `LibB`.

Finally, I have an executable in package `my-package-C` which `build-depends` on `my-package-A` (only), and has `Main.hs`:
~~~haskell
{-# LANGUAGE PackageImports #-}

module Main (main) where

import "my-package-A" LibB (someFuncB)

main :: IO ()
main = print someFuncB
~~~

With `stack --resolver ghc-9.2.4 build`, it all builds as expected.

However, with `stack --resolver ghc-9.4.2 build`, and all else equal, the build fails with Cabal message:
~~~text
my-package-C> app\Main.hs:6:1: error:
my-package-C> Could not find module ‘LibB’
my-package-C> Perhaps you meant
my-package-C> LibB (from my-package-A-0.1.0.0, reexporting LibB)
my-package-C> LibA (from my-package-A-0.1.0.0)
my-package-C> |
my-package-C> 6 | import "my-package-A" LibB (someFuncB)
my-package-C> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
~~~

I can't make sense of the error message. I've requested `LibB` be imported from package `my-package-A` and I'm told it can't be found but perhaps I mean `LibB` reexported by `my-package-A`?

However, if I change (only) `Main.hs` to (no package-qualified import):
~~~
module Main (main) where

import LibB (someFuncB)

main :: IO ()
main = print someFuncB
~~~

`stack --resolver ghc-9.4.2 build` now works! That is why I think it is a bug.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.