-
Notifications
You must be signed in to change notification settings - Fork 20
Using with stack
Stack support is limited. This page contains some tricks that can help to coerce ghc-mod into cooperation.
Should not be required with haskell-ghc-mod 1.6.0 and up. Please create issue if it doesn't work
Stack manages multiple ghc installations using environment hacking. So, in order to bring this environment into scope when using Atom, the most straightforward way is to run Atom with stack exec atom
from project directory.
DO NOT specify full path to ghc-mod/ghc-modi in haskell-ghc-mod settings. Do not add anything to 'Additional Path Directories' as well, unless you need to (i.e. know what you're doing).
Ghc-mod requires that it must be built with the same version of GHC that you use to build your project. In most cases this means that you need a separate ghc-mod installation for every distinct stack resolver you're using.
Simplest way to achieve this would be to install ghc-mod locally for every stack project you want to use it with, i.e. run stack build ghc-mod
in project directory (if you have multiple stack.yaml
configs, do this for each one). If this fails for some reason, try to use stack-installed ghc (with stack --no-system-ghc --install-ghc build ghc-mod
). Note that some resolvers seemingly can't build ghc-mod at all. You might also want to install newer ghc-mod version than a given resolver offers. Refer to stack documentation on how exactly you could do that.
With lts-4.1 resolver (and probably later), you can also install ghc-mod into 'global project' (essentially run stack build ghc-mod
outside any project directory). This will automatically provide ghc-mod executables to all projects using this resolver (so you don't need to install it per-project). Note this does not work with lts-3.22.
This should go without saying. It's always a bad idea to mix packages installed with stack and cabal-install. At least avoid mixing those in the same project, i.e. if you're using stack, use stack-installed ghc-mod. If you're using cabal-install, use cabal-installed ghc-mod. Yes, it is not exactly simple.