I use ormolu to format the code in my (Stack) project. Today I tried to update to the Stackage 24.69 LTS (with GHC 9.10.3), and I realized ormolu is not in the package set.
I tried various combinations of adding various versions of ormolu to extra-deps, but there were various other version conflicts with other packages. Eventually, I found something that at least lets my project build:
…but then I realized that this breaks HLS in my project. (I start seeing Cabal-syntax version errors when trying to start the HLS server.)
What are my options? I just want people who use my project to be able to format the code with a consistent version of ormolu. (I don’t even care which version!) But I also was hoping to use GHC 9.10.3. And obviously I want HLS to work! I didn’t expect this to be such a challenge…
So far the only thing I can think to do is switch my LTS to 23.28 (ghc-9.8.4) instead, which contained ormolu. But that seems a silly reason to make my entire project depend on an older version of GHC!
(If it’s helpful, here’s a link to the relevant diff in my stack.yaml.)
I appreciate any advice!
EDIT: I thought I could try switching to Fourmolu instead, but then I realized that it is also not in the Stackage 24.69 snapshot
IMO ormolu/fourmolu doesn’t belong in your stack.yaml dependencies. Just install with ghcup and be on your way.
One technique I like to use in my projects is use dotslash, which guarantees anyone contributing uses the same version when running tools/fourmolu ...args
Yeah, it’s not a code dependency, so that makes sense. I only added it a day or two ago because it seemed a reasonable way to enforce a version on a tool in a consistent way within the repo. I can throw something like this into a Makefile:
stack exec --package ormolu -- ormolu [whatever]
…and it worked! Until I tried to change my Stackage LTS today, that is. Many other build tools I’ve worked with in other languages allow for something similar.
Is there a better way to do something like this without adding another external tool like dotslash? It seemed like it’d be in the Stack wheelhouse, which is why I thought it made sense to use Stack in this way.
I didn’t even know you could do this! I thought GHCup was just for GHC, HLS, cabal, and stack.
Incidentally, I’m seeing these HLS errors even without adding Cabal-syntax to my extra-deps – it seems HLS is erroring out specifically just from my switching to GHC 9.10.3. Works fine with GHC 9.6.x and 9.8.x. (With HLS 2.14.0.0.)
…but that’s another issue , I don’t mean to distract this thread.
I guess, worst case, I can just put in the readme: “install ormolu on your system before running make format” or whatever… or just use a tool like dotslash.
It’s just, what I like so much about Stack is that it’s self-contained. Anybody, without knowing anything about Haskell tooling, can install Stack and cd into a project and type stack build and it all just works in a consistent way. It makes everything easier, IMO… contributing, CI, testing on random systems, etc.