vigoo's software development blog

Gradle-Haskell-plugin with experimental Stack support

Posted on December 22, 2015

I've released a new version (0.4) of gradle-haskell-plugin today, with experimental stack support. It is not enabled by default, but I used it exclusively for months and it seems to get quite stable. To use it you need stack, have it enabled with -Puse-stack and have to keep some rules in your .cabal file, as explained in the README.

How does it work?

The core idea did not change compared to the original, cabal based solution.

To support chaining the binary artifacts, I had to add a new option to stack called extra package databases. The databases listed in this section are passed after the global but before the snapshot and the local databases, which means that the snapshot database cannot be used (the packages in the binary artifacts are not "seeing" them). This sounds bad, but gradle-haskell-plugin does a workaround; it generates the stack.yaml automatically, and in a way that:

With this approach we get the same behavior that was already proven in cabal mode, but with the advantage that the generated stack.yaml completely defines the project for any tool that knows stack. So after gradle extracted the dependencies and generated the stack.yaml, it is no longer needed to succesfully compile/run/test the project, which means that tools like IDE integration will work much better than with the more hacky cabal mode of the plugin.