Upgrading Coinbase-Pro to ghc 8.8.3 From 8.6.5
Upgrading to a newer version of GHC is relatively painless when using
stack to maintain the Haskell toolchain for a Haskell package. The workflow looks generally like this:
1) Change the resolver 2) Bump dependency version numbers 3) Make code modifications to account for breaking API changes (if any)
I'm going to demonstrate by upgrading the coinbase-pro package that I maintain.
Changing the resolver
First step is to change the
resolver parameter in the project's
stack.yaml. The latest lts for GHC 8.8.3 is
lts-16.7, so that's what the new resolver should be:
resolver: lts-16.7 ghc-options: "$locals": -Wall packages: - . extra-deps: - unagi-streams-0.2.6 - unagi-chan-0.4.1.3 system-ghc: false extra-include-dirs: ["/usr/local/opt/openssl/include"] extra-lib-dirs: ["/usr/local/opt/openssl/lib"]
Now I can just
stack build and have stack tell me what package dependencies I need to change. Here is the stack output I get after changing the resolver:
Error: While constructing the build plan, the following exceptions were encountered: In the dependencies for coinbase-pro-0.8.0.0: network-18.104.22.168 from stack configuration does not match >=2.6 && <2.9 (latest matching version is 22.214.171.124) time-1.9.3 from stack configuration does not match ==1.8.* (latest matching version is 126.96.36.199) needed since coinbase-pro is a build target. Some different approaches to resolving this: * Set 'allow-newer: true' in /home/mdunn/.stack/config.yaml to ignore all version constraints and build anyway. * Recommended action: try adding the following to your extra-deps in /home/mdunn/Code/coinbase-pro/stack.yaml: - network-188.8.131.52@sha256:0f165dffa752d8cde30c2bde86f80609c4f1dc5eeb3182d593041f97839c5b3b,3011 - time-184.108.40.206@sha256:3f6eddf238b828eb4f82683acce1c3afe64784f0d20114239b738c123316c85c,5494
So stack is telling me that two packages can't be reconciled given the existing version bounds for the packages. Currently, I have the network and time package bounds set to:
- network >= 2.6 && < 2.9 - time >= 1.8 && < 1.9
This is problematic, considering the package versions that come packaged with
1.9.3 respectively. I'll need to increase the upper bounds of these two packages to allow for newer versions:
- network >= 2.6 && < 3.2 - time >= 1.8 && < 2
If you'll notice though, I'm attempting to upgrade the
network library to a new major release (2.x vs 3.x), so I'll expect to have to make some code changes (and testing) to be sure that everything still works properly with the new
network package. As for time, I can be sure that not much as changed considering it is just a minor version upgrade – but you can never be too careful!
stack build now results in the following error:
/home/mdunn/Code/coinbase-pro/src/lib/CoinbasePro/Environment.hs:11:43: error: Module ‘Network.Socket.Internal’ does not export ‘PortNumber’ | 11 | import Network.Socket.Internal (PortNumber) | ^^^^^^^^^^
Ok, interesting, so it doesn't look like the
network library doesn't expose
Network.Socket.Internal. The latest docs show that
PortNumber is just exposed through
Network.Socket. It was probably a mistake to import
Network.Socket.Internal in the first place; usually importing from modules with
Internal namespace is a red flag!
The new import is as such:
import Network.Socket (HostName, PortNumber)
Now I can finish my build.
After upgrading to the new lts, I'll increment the minor version of the package and push it up to github and make a new release! As you can see, using
stack to help guide you through managing dependencies is a fairly straight-forward process.
Here is the changeset that was made in this post.
Here is the newest changeset after I realized that I migrated the code incorrectly the first time.