That was a problem commonly called 'cabal hell'. You can alternatively use the stack build tool, https://github.com/commercialhaskell/stack, which works by fixing package versions against stackage snapshots.
Before using stack I was always afraid to come back to a Haskell project after a few months, since using stack that's not a problem. Also, you don't have to worry about different machines, because stack is ensuring that you have the pretty much same build environment (at least the Haskell packages will have the exact same version).
Stack also recently added support for using Nix to solve the problem fixing non-Haskell dependencies for a project.
Before using stack I was always afraid to come back to a Haskell project after a few months, since using stack that's not a problem. Also, you don't have to worry about different machines, because stack is ensuring that you have the pretty much same build environment (at least the Haskell packages will have the exact same version).
Stack also recently added support for using Nix to solve the problem fixing non-Haskell dependencies for a project.