- Compatibility Chart
- Compatibility Pearls
- Intent: For
4.n, do X
- Optional dependencies based on GHC version
- Misc. Ecosystem Pearls
Table of Contents
4.n, do X
The Hackage Matrix Builder is a great way to track how compatible a library is with historical versions of GHC (and therefore
As a library author, if you've ever attempted to support more than the most recent versions of GHC, then you've been tossed around the ocean of
MonadFail, with CPP as your only olive branch.
This post is a reference for library authors to easily track how
base evolves, and how to deal with its changes. This is so that we don't all have to repeat the same labour of digging through GHC release notes or the
base CHANGELOG to find out what works. I will update this post as time goes on, so please feel free to bookmark it or even help update it.
|GHC||Stackage LTS||Cabal||Notable Changes|
|9.2||4.16||20||Record Dot Syntax available|
|GHC2021 extension set|
4.n, do X
A construction like
#if __GLASGOW_HASKELL__ < 841 is also possible, but I find this less clear than comparing against
This will allow your library to support GHC >= 8.0. Excluding this CPP will limit your compatibility to GHC >= 8.4.
For instance, until GHC 8.0, the
Semigroup typeclass was not in
base. The following will include the
semigroups dependency, but only when it detects that you need it:
library build-depends: base >= 4.8 && < 5 ... if !impl(ghc >= 8.0) build-depends: semigroups >= 0.8.4 && < 1
build-depends sections like this combine, they don't override one another.
There are a number of packages that smooth the transition between compiler versions by backporting newer functionality. The major ones are:
base-compatbut with more dependencies
To see all such libraries, search for "compat" on Hackage.
these-1 the project underwent a structural change. Its extended dependency graph is now "opt out", and the following can be added to a
stack.yaml to accomplish this:
these-1.0.1, set this instead:
wither :: Applicative f => (a -> f (Maybe b)) -> t a -> f (t b) is a convenient function from the
witherable package. As of 2019 December, the core typeclass and functions are available with minimal dependencies via the
This trick lets your library/program have programmatic access to the
version: value you specified in your