Skip to content
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

Avoid importing by generating exact names directly #14

Closed
wants to merge 1 commit into from

Conversation

tfausak
Copy link
Owner

@tfausak tfausak commented Mar 30, 2024

Fixes #12.

All the types line up, but unfortunately this doesn't work as written. Given a simple module like this:

{-# OPTIONS_GHC -fplugin=Imp #-}

main :: System.IO.IO ()
main = System.IO.print ()

It fails to compile:

Main.hs:3:9: error: [GHC-83249]
    Can't find interface-file declaration for type constructor or class System.IO.IO
      Probable cause: bug in .hi-boot file, or inconsistent .hi file
      Use -ddump-if-trace to get an idea of which file caused the error
  |
3 | main :: System.IO.IO ()
  |         ^^^^^^^^^^^^

Curiously it works fine without the type signature.

@tfausak
Copy link
Owner Author

tfausak commented Mar 30, 2024

Running with -ddump-if-trace outputs a lot of stuff. Here's the last bit, right before the error:

updating EPS
Considering whether to load GHC.Prim.Ext {- SYSTEM -}
Reading interface for ghc-prim:GHC.Prim.Ext;
    reason: Loading orphan modules (GHC.Prim.Ext)
readIFace /Users/taylor/.ghcup/ghc/9.8.2/lib/ghc-9.8.2/lib/../lib/aarch64-osx-ghc-9.8.2/ghc-prim-0.11.0-f42f/GHC/Prim/Ext.hi
updating EPS
newGlobalBinder Main main Main.hs:6:1-4
                main
Need decl for IO
Considering whether to load System.IO {- SYSTEM -}

@tfausak tfausak added the enhancement New feature or request label Mar 30, 2024
@tfausak
Copy link
Owner Author

tfausak commented Mar 31, 2024

I'm closing this because it's already drifted pretty substantially. Also I'm not sure that this approach is actually any better. I'm sure it's possible to solve the problem I ran into here, but it feels like I'll be recreating import logic by hand in my plugin, which doesn't seem like a good idea.

@tfausak tfausak closed this Mar 31, 2024
@tfausak tfausak deleted the gh-12-rdr-name-exact branch March 31, 2024 17:26
@tfausak tfausak mentioned this pull request Mar 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generate names directly?
1 participant