I am using Stack to setup, build, and run my Haskell projects from the command line. I want to use IntelliJ as my IDE but am running into problems configuring Stack as my build tool.
I used Stack to create and run a "Hello, World" Haskell program on the command line following the instructions in the Stack User Guide. Everything worked fine.
I have the HaskForce plugin installed on IntelliJ. The Build, Execution, Deployment -> Compiler -> Haskell Compiler tab gives you a choice between building with Stack and building with Cabal. I selecte Build with stack and configured it like so.
I can run the project using a Haskell Stack Run configuration. The console output is correct.
/Users/williammcneill/Library/Haskell/bin/stack exec hellohaskell-exe --
Hello, Haskell.
However, I cannot figure out how to rebuild the project through the IDE. For example, if I change the output text and rerun the program, I still see the original "Hello, Haskell" output. Build -> Make Project | Make Module | Rebuild Project all do nothing.
The Project Settings->Artifacts tab has nothing listed, and I don't see a way to add a Haskell executable here.
My workaround is to build my Haskell programs from the command line even when I'm editing from the IDE.
(It also looks strange to me to specify a path to a project-specific stack.yaml
file in the general Haskell compiler settings, but that was the only way I could see how to use Stack to build.)
How do I set up IntelliJ to build Haskell projects using Stack?
ghc 7.10.3, stack 1.1.2, HaskForce 0.3-beta.33, IntelliJ IDEA Ultimate 2016.1.3, OS X 10.11.5
This is Haskforce issue 282.
Haskell language support. This plugin depends mainly on Stack. It can create new Stack projects and import existing Stack projects.
Stack is a modern, cross-platform build tool for Haskell code.
Stack is a cross-platform program for developing Haskell projects. It is intended for Haskellers both new and experienced. See haskellstack.org or the doc directory for more information.
If you want to hit the IntelliJ run button to run the project and use Stack, I think you should use the IntelliJ Haskell Plugin as @mrek said. The HaskForce plugin says at the moment
Note: Run configurations are not supported for stack at the moment. This is for cabal projects only.
The install instructions for everything (from installing Stack to project setup) are in the readme, but I needed to change it slightly so I put my version here.
Installation instructions for everyone who wants to use Haskell
stack install hindent
and stack install stylish-haskell
(this can take a while).C:\Users\username\AppData\Roaming\local\bin\stack.exe
or /usr/bin/stack
) and Set Default (if it is not already default).
app/Main.hs
. You could replace everything in it with main = putStrLn "Hello Haskell!"
.You can start up the interactive console by clicking Terminal at the bottom of IntelliJ and then running stack ghci
. When you type main
you are calling main, and so on.
You could also use stack test
instead of the test run configuration.
I suppose you have IntelliJ Haskell plugin installed.
Now, you should be able to build the project.
Output:
/usr/local/bin/stack build --exec test-project-exe
It works!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With