Speed โ€‹โ€‹up compiling a Haskell stack project and git branches

I cannot change the GHC compile time, but I can control the environment in which things are compiled. What can I do with git and the stack to minimize downtime due to (re) builds?

The Haskell stack caches compiled dependencies in a directory .stack-work

, which is great for working on one thing at a time. However, I find myself switching between branches. I did it git checkout

in place and maybe some kind of cache .stack-work

can be used. But I prefer to git worktree

get a copy of the branch in a different directory. Worktree is especially complicated in build time since each worktree will have its own .stack-work

and therefore must download / configure / compile / install its own dependencies rather than use existing ones.

I've read about Nix and Haskell, but since the stack creates its own cache, it ignores whatever Nix compiles and installs. From what I've read, I really want Nix to handle dependencies and a stack to handle my personal code. I get a lot of benefit from stackage and stack solver

therefore I don't want to give up on them. But when I see the "unregistering" onscreen message at startup stack build --only-dependencies && stack ghci

, I know I have at least 10-15 minutes before I get the prompt.

Many thanks!

+3


source to share





All Articles