Skip to content
This repository has been archived by the owner on Oct 7, 2020. It is now read-only.

Possible to use additional ghc-option "-fplugin=X"? #1264

Closed
cah6 opened this issue May 21, 2019 · 11 comments
Closed

Possible to use additional ghc-option "-fplugin=X"? #1264

cah6 opened this issue May 21, 2019 · 11 comments
Assignees
Milestone

Comments

@cah6
Copy link

cah6 commented May 21, 2019

My current issue: I'm working on code that uses Polysemy, which uses a custom plugin to drive some type inference. This is usually enabled by adding -fplugin=Polysemy.Plugin to ghc-options section of cabal file; see https://github.com/isovector/polysemy/tree/master/polysemy-plugin.

However, it looks like when HIE is running through my IDE (currently VSCode), it's not using this plugin ghc-options override so I see compile errors in my IDE even though there aren't any when compiling through command line.

Is there a way to specify additional GHC options like this custom plugin when interfacing with HIE?

@mpickering
Copy link
Collaborator

What about as a workaround if you put it as an OPTIONS_GHC pragma in each file? Does that work?

@cah6
Copy link
Author

cah6 commented May 21, 2019

Yeah, I had tried that as a workaround but unfortunately it didn't work; it gave the same compile error in my IDE as if it wasn't there.

@mpickering
Copy link
Collaborator

I don't understand really how the the pragma would be ignored if it was in the source file. Would be good to see if anyone else can reproduce this.

@cah6
Copy link
Author

cah6 commented May 21, 2019

I was a bit surprised by that too; I can provide a repo with an example a bit later tonight.

@fendor
Copy link
Collaborator

fendor commented May 22, 2019

I will try to reproduce it.

@fendor
Copy link
Collaborator

fendor commented May 22, 2019

Test repository: polysemy-hie-experiment
Reproduces the problem, the project builds, but hie shows an error.
Output of local vscode project:

Output of Hie
info: Found Stack project at: /home/baldr/Documents/haskell/polysemy-eUsing hie version: Version 0.9.0.0 x86_64 ghc-8.6.4
xperiment
info: Using Stack project at: /home/baldr/Documents/haskell/polysemy-experiment
info: Found Stack pUsing hoogle db at: /home/baldr/.hoogle/default-haskell-5.0.17.hoo
roject at: /home/baldr/Documents/haskell/polysemy-experiment
info: Using Stack project at: /home/baldr/Documents/haskell/polysemy-experiment
DEBUG: setup configuration is out of date
DEBUG: reconfiguring Stack project
Building all executables for `polysemy-experiment' once. After a successful build of all of them, only specified executables will be rebuilt.
polysemy-experiment-0.1.0.0: configure (exe)
Configuring polysemy-experiment-0.1.0.0...
DEBUG: regenerating cache: /home/baldr/Documents/haskell/polysemy-experiment/.stack-work/dist/x86_64-linux-nix/Cabal-2.4.0.1/setup-config.ghc-mod.cabal-components (cache missing or unreadable)
DEBUG: writing memory cache: /home/baldr/Documents/haskell/polysemy-experiment/.stack-work/dist/x86_64-linux-nix/Cabal-2.4.0.1/setup-config.ghc-mod.cabal-components
DEBUG: resolveEntrypoint:
       ["-i","-i.stack-work/dist/x86_64-linux-nix/Cabal-2.4.0.1/build/polysemy-experiment-exe/polysemy-experiment-exe-tmp","-iapp","-i.stack-work/dist/x86_64-linux-nix/Cabal-2.4.0.1/build/polysemy-experiment-exe/autogen","-i.stack-work/dist/x86_64-linux-nix/Cabal-2.4.0.1/build/global-autogen","-I.stack-work/dist/x86_64-linux-nix/Cabal-2.4.0.1/build/polysemy-experiment-exe/autogen","-I.stack-work/dist/x86_64-linux-nix/Cabal-2.4.0.1/build/global-autogen","-I.stack-work/dist/x86_64-linux-nix/Cabal-2.4.0.1/build/polysemy-experiment-exe/polysemy-experiment-exe-tmp","-I/nix/store/czyhm7dgjsxl13smx4y9b2msiq4lq4hb-ghc-8.6.4/include","-I/nix/store/dhcvj12clmpwri8vbi4xnh4hwcbx90q9-gmp-6.1.2-dev/include","-I/nix/store/dzfc521a263nvavg31kh9vi9l8ql8nvv-git-2.19.2/include","-I/nix/store/ghzg4kg0sjif58smj2lfm2bdvjwim85y-gcc-wrapper-7.4.0/include","-optP-include","-optP.stack-work/dist/x86_64-linux-nix/Cabal-2.4.0.1/build/polysemy-experiment-exe/autogen/cabal_macros.h"]
DEBUG: resolveEntrypoint: []
DEBUG: making sure autogen files exist
DEBUG: autogen files out of sync
DEBUG: writing Cabal autogen files
DEBUG: resolvedComponentsCache: files changed: none
DEBUG: resolveGmComponent:
       ["-optP-include","-optP.stack-work/dist/x86_64-linux-nix/Cabal-2.4.0.1/build/autogen/cabal_macros.h"]
DEBUG: resolveGmComponent:
       ["-i","-i.stack-work/dist/x86_64-linux-nix/Cabal-2.4.0.1/build/polysemy-experiment-exe/polysemy-experiment-exe-tmp","-iapp","-i.stack-work/dist/x86_64-linux-nix/Cabal-2.4.0.1/build/polysemy-experiment-exe/autogen","-i.stack-work/dist/x86_64-linux-nix/Cabal-2.4.0.1/build/global-autogen","-I.stack-work/dist/x86_64-linux-nix/Cabal-2.4.0.1/build/polysemy-experiment-exe/autogen","-I.stack-work/dist/x86_64-linux-nix/Cabal-2.4.0.1/build/global-autogen","-I.stack-work/dist/x86_64-linux-nix/Cabal-2.4.0.1/build/polysemy-experiment-exe/polysemy-experiment-exe-tmp","-I/nix/store/czyhm7dgjsxl13smx4y9b2msiq4lq4hb-ghc-8.6.4/include","-I/nix/store/dhcvj12clmpwri8vbi4xnh4hwcbx90q9-gmp-6.1.2-dev/include","-I/nix/store/dzfc521a263nvavg31kh9vi9l8ql8nvv-git-2.19.2/include","-I/nix/store/ghzg4kg0sjif58smj2lfm2bdvjwim85y-gcc-wrapper-7.4.0/include","-optP-include","-optP.stack-work/dist/x86_64-linux-nix/Cabal-2.4.0.1/build/polysemy-experiment-exe/autogen/cabal_macros.h","-XHaskell2010","-optP-include","-optP.stack-work/dist/x86_64-linux-nix/Cabal-2.4.0.1/build/autogen/cabal_macros.h"]
DEBUG: regenerating cache: .stack-work/dist/x86_64-linux-nix/Cabal-2.4.0.1/setup-config.ghc-mod.resolved-components (cache missing or unreadable)
DEBUG: writing memory cache: .stack-work/dist/x86_64-linux-nix/Cabal-2.4.0.1/setup-config.ghc-mod.resolved-components
VOMIT: hide all packages(ignore .ghc.environment):: DontLoadGhcEnvironment
VOMIT: Using the following mapped files: "/home/baldr/Documents/haskell/polysemy-experiment/app/Main.hs"
VOMIT: Using the following mapped files: "/home/baldr/Documents/haskell/polysemy-experiment/app/Main.hs"
VOMIT: Initializing GHC session with following options: "-fbuilding-cabal-package" "-O" "-outputdir" ".stack-work/dist/x86_64-linux-nix/Cabal-2.4.0.1/build/polysemy-experiment-exe/polysemy-experiment-exe-tmp" "-odir" ".stack-work/dist/x86_64-linux-nix/Cabal-2.4.0.1/build/polysemy-experiment-exe/polysemy-experiment-exe-tmp" "-hidir" ".stack-work/dist/x86_64-linux-nix/Cabal-2.4.0.1/build/polysemy-experiment-exe/polysemy-experiment-exe-tmp" "-stubdir" ".stack-work/dist/x86_64-linux-nix/Cabal-2.4.0.1/build/polysemy-experiment-exe/polysemy-experiment-exe-tmp" "-i" "-i.stack-work/dist/x86_64-linux-nix/Cabal-2.4.0.1/build/polysemy-experiment-exe/polysemy-experiment-exe-tmp" "-iapp" "-i.stack-work/dist/x86_64-linux-nix/Cabal-2.4.0.1/build/polysemy-experiment-exe/autogen" "-i.stack-work/dist/x86_64-linux-nix/Cabal-2.4.0.1/build/global-autogen" "-I.stack-work/dist/x86_64-linux-nix/Cabal-2.4.0.1/build/polysemy-experiment-exe/autogen" "-I.stack-work/dist/x86_64-linux-nix/Cabal-2.4.0.1/build/global-autogen" "-I.stack-work/dist/x86_64-linux-nix/Cabal-2.4.0.1/build/polysemy-experiment-exe/polysemy-experiment-exe-tmp" "-I/nix/store/czyhm7dgjsxl13smx4y9b2msiq4lq4hb-ghc-8.6.4/include" "-I/nix/store/dhcvj12clmpwri8vbi4xnh4hwcbx90q9-gmp-6.1.2-dev/include" "-I/nix/store/dzfc521a263nvavg31kh9vi9l8ql8nvv-git-2.19.2/include" "-I/nix/store/ghzg4kg0sjif58smj2lfm2bdvjwim85y-gcc-wrapper-7.4.0/include" "-optP-include" "-optP.stack-work/dist/x86_64-linux-nix/Cabal-2.4.0.1/build/polysemy-experiment-exe/autogen/cabal_macros.h" "-hide-all-packages" "-Wmissing-home-modules" "-no-user-package-db" "-package-db" "/home/baldr/.stack/snapshots/x86_64-linux-nix/lts-13.16/8.6.4/pkgdb" "-package-db" "/home/baldr/Documents/haskell/polysemy-experiment/.stack-work/install/x86_64-linux-nix/lts-13.16/8.6.4/pkgdb" "-package-id" "base-4.12.0.0" "-package-id" "polysemy-0.1.2.1-LtdTFXTVLKS9FCTXMz8Fdx" "-package-id" "polysemy-plugin-0.1.0.1-FMe8hlIwXFrKrwQ1p6TM9a" "-XHaskell2010" "-threaded" "-rtsopts" "-with-rtsopts=-N" "-fplugin=Polysemy.Plugin" "-Wno-missing-home-modules" "-O0" "-fno-warn-missing-home-modules" "-Wwarn"
DEBUG: initSession: Session not initialized, creating new one
VOMIT: Using the following targets: "/home/baldr/Documents/haskell/polysemy-experiment/app/Main.hs" "/home/baldr/Documents/haskell/polysemy-experiment/app/Main.hs"
DEBUG: loadTargets:
       Loading: /run/user/1000/ghc-mod4417/Main4416-0.hs
DEBUG: loadTargets: filterModSums: True
DEBUG: loadTargets:
       Ambiguous use of effect 'State'
Possible fix:
  add (Member (State Integer) r) to the context of 
    the type signature
If you already have the constraint you want, instead
  add a type application to specify
    'Integer' directly
DEBUG: loadTargets: Loading done

@mpickering
Copy link
Collaborator

We are probably missing the call which initialises plugins. When the DynFlags are initialized there also needs to be a call to initializePlugins. Could you add this @fendor ?

@fendor
Copy link
Collaborator

fendor commented May 22, 2019

will try!

@isovector
Copy link

Just linking back to the polysemy issue so that I can be notified when this gets solved! polysemy-research/polysemy#53

@fendor
Copy link
Collaborator

fendor commented May 27, 2019

Issue is addressed in #20

@fendor fendor self-assigned this May 29, 2019
@fendor
Copy link
Collaborator

fendor commented Jun 16, 2019

Closed by #1293

@fendor fendor closed this as completed Jun 16, 2019
@alanz alanz added this to the 2019-06 milestone Jul 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants