-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot use modules from same package #11
Comments
I initially thought this could be related to "implicit" imports (#5), but I get the same error either way. This GHC issue is kind of related: https://gitlab.haskell.org/ghc/ghc/-/issues/21730 I could, as that issue suggests, replace the import with an |
I think there's nothing that Imp can do about this. The earliest a plugin can do anything is in Either this can be considered a GHC bug, or it's just a limitation of what Imp can do. I'll open an upstream ticket to see what GHC devs have to say. |
I created an upstream issue for this: https://gitlab.haskell.org/ghc/ghc/-/issues/24579 In the meantime, it might suffice to say that Imp can't be used to import modules from the same unit (component). |
The title of this issue says "same package" but really it means "same component". You can work around this problem by referring to modules from another component, like a sub-library. For example: -- example.cabal
cabal-version: 3.8
name: example
version: 0
common library
build-depends: base, imp
ghc-options: -fplugin=Imp
library a
import: library
hs-source-dirs: a
exposed-modules: A
library b
import: library
hs-source-dirs: b
build-depends: example:a
exposed-modules: B -- a/A.hs
module A where
mainA = System.IO.print 'a' -- b/B.hs
module B where
mainB = A.mainA |
Upstream has confirmed that this is simply a limitation of GHC plugins. Imp cannot support this, so all I need to do is update the documentation to say that. |
Consider a simple package like this:
This should work since
B
should just importA
, but if you actually try to build it you'll get an error:I'm guessing that this happens because GHC figures out the topographic sort of modules before actually compiling them. Since the import isn't actually in the file, GHC is free to compile them in either order. Or, more to the point, it doesn't have to make
A
available toB
.Relevant documentation for
getImports
: https://hackage.haskell.org/package/ghc-9.8.2/docs/GHC-Parser-Header.html#v:getImportsThe text was updated successfully, but these errors were encountered: