diff --git a/CHANGES.md b/CHANGES.md
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,3 +1,12 @@
+## [v0.4.0.2](https://github.com/diagrams/diagrams-haddock/tree/v0.4.0.2) (2018-06-25)
+
+A bunch of upper bound updates etc.:
+
+- Allow `lens-4.16`, `Cabal-2.2` `QuickCheck-2.11`,
+  `haskell-src-exts-1.20`, `tasty-1.1`, `tasty-quickcheck-0.10`,
+  `ansi-terminal-0.8`
+- Updates to work with several different versions of `Cabal`
+
 ## [v0.4.0.1](https://github.com/diagrams/diagrams-haddock/tree/v0.4.0.1) (2016-11-28)
 
 - Allow `haskell-src-exts-1.19` and `haskell-src-exts-simple-1.19`
diff --git a/diagrams-haddock.cabal b/diagrams-haddock.cabal
--- a/diagrams-haddock.cabal
+++ b/diagrams-haddock.cabal
@@ -1,5 +1,5 @@
 name:                diagrams-haddock
-version:             0.4.0.1
+version:             0.4.0.2
 synopsis:            Preprocessor for embedding diagrams in Haddock documentation
 description:         diagrams-haddock is a tool for compiling embedded inline
                      diagrams code in Haddock documentation, for an
@@ -23,7 +23,7 @@
 bug-reports:         https://github.com/diagrams/diagrams-haddock/issues
 category:            Graphics
 build-type:          Simple
-cabal-version:       >=1.10
+cabal-version:       1.18
 extra-source-files:  README.md, CHANGES.md, diagrams/*.svg
 extra-doc-files:     diagrams/*.svg
 tested-with:         GHC == 7.10.2, GHC == 8.0.1
@@ -35,7 +35,7 @@
 library
   exposed-modules:     Diagrams.Haddock
   other-modules:       Paths_diagrams_haddock
-  build-depends:       base >= 4.4 && < 5.0,
+  build-depends:       base >= 4.4 && < 4.12,
                        filepath,
                        directory,
                        mtl >= 2.0 && < 2.3,
@@ -44,31 +44,32 @@
                        bytestring >= 0.9 && < 0.11,
                        strict >= 0.3 && < 0.4,
                        parsec >= 3,
-                       haskell-src-exts >= 1.18 && < 1.20,
+                       haskell-src-exts >= 1.18 && < 1.21,
                        svg-builder >= 0.1 && < 0.2,
                        diagrams-builder >= 0.5 && < 0.9,
                        diagrams-lib >= 1.4 && < 1.5,
                        diagrams-svg >= 1.4 && < 1.5,
-                       lens >= 3.8 && < 4.16,
+                       lens >= 3.8 && < 4.17,
                        linear >= 1.10 && < 1.21,
                        cpphs >= 1.15,
                        cautious-file >= 1.0 && < 1.1,
                        uniplate >= 1.6 && < 1.7,
                        text >= 0.11 && < 1.3,
                        base64-bytestring >= 1 && < 1.1,
-                       ansi-terminal >= 0.5 && < 0.7
+                       ansi-terminal >= 0.5 && < 0.9
   hs-source-dirs:      src
   other-extensions:    TemplateHaskell
   default-language:    Haskell2010
 
 Executable diagrams-haddock
   main-is:             diagrams-haddock.hs
+  other-modules:       Paths_diagrams_haddock
   build-depends:       base,
                        directory,
                        filepath,
                        diagrams-haddock,
                        cmdargs >= 0.8 && < 0.11,
-                       Cabal >= 1.14 && < 1.25,
+                       Cabal >= 1.14 && < 2.3,
                        cpphs >= 1.15
   hs-source-dirs:      tools
   default-language:    Haskell2010
@@ -78,12 +79,12 @@
   main-is:             Tests.hs
   build-depends:       base,
                        containers >= 0.4 && < 0.6,
-                       QuickCheck >= 2.4 && < 2.10,
-                       tasty >= 0.8 && < 0.12,
-                       tasty-quickcheck >= 0.8 && < 0.9,
+                       QuickCheck >= 2.4 && < 2.12,
+                       tasty >= 0.8 && < 1.2,
+                       tasty-quickcheck >= 0.8 && < 0.11,
                        parsec >= 3,
-                       lens >= 3.8 && < 4.16,
-                       haskell-src-exts >= 1.18 && < 1.20,
+                       lens >= 3.8 && < 4.17,
+                       haskell-src-exts >= 1.18 && < 1.21,
                        diagrams-haddock
   hs-source-dirs:      test
   default-language:    Haskell2010
diff --git a/tools/diagrams-haddock.hs b/tools/diagrams-haddock.hs
--- a/tools/diagrams-haddock.hs
+++ b/tools/diagrams-haddock.hs
@@ -1,10 +1,10 @@
+{-# LANGUAGE CPP                #-}
 {-# LANGUAGE DeriveDataTypeable #-}
 {-# LANGUAGE TupleSections      #-}
 module Main where
 
 import           Control.Monad                      (forM_, when)
 import           Data.List                          (intercalate)
-import           Data.Version                       (showVersion)
 import           Diagrams.Haddock
 import           System.Console.CmdArgs
 import           System.Directory
@@ -21,6 +21,48 @@
 
 import           Paths_diagrams_haddock             (version)
 
+------------------------------------------------------------
+-- This is officially an awful mess.
+--
+-- In Cabal < 2.0, it used the Version type from Data.Version.
+--
+-- As of Cabal 2.0, Cabal switched to its own Version type in
+-- Distribution.Version, and re-exported a 'showVersion' function.
+--
+-- As of Cabal 2.2, showVersion became deprecated and a 'prettyShow'
+-- function was added;  Version moved to Distribution.Types.Version.
+--
+-- We need to show both Cabal versions and Data.Version
+-- versions, hence the CPP mess below.
+
+-- 1. We definitely need Data.Version. Import it qualified.
+import qualified Data.Version                       as V
+
+-- 2. Import the proper 'Version' type to refer to Cabal versions, and
+-- the proper function for showing it.
+#if MIN_VERSION_Cabal(2,2,0)
+import           Distribution.Types.Version         (Version)
+import           Distribution.Pretty                (prettyShow)
+#elif MIN_VERSION_Cabal(2,0,0)
+import           Distribution.Version               (Version)
+import qualified Distribution.Version               as DV
+#else
+import           Data.Version                       (Version)
+#endif
+
+-- 3. Define a function for showing Cabal versions.
+showCabalVersion :: Version -> String
+#if   MIN_VERSION_Cabal(2,2,0)
+showCabalVersion = prettyShow
+#elif MIN_VERSION_Cabal(2,0,0)
+showCabalVersion = DV.showVersion
+#else
+showCabalVersion = V.showVersion
+#endif
+
+------------------------------------------------------------
+------------------------------------------------------------
+
 data DiagramsHaddock
   = DiagramsHaddock
   { quiet       :: Bool
@@ -76,8 +118,8 @@
   }
   &= program "diagrams-haddock"
   &= summary (unlines
-       [ "diagrams-haddock v" ++ showVersion version ++ ", (c) 2013-2016 diagrams-haddock team (see LICENSE)"
-       , "compiled using version " ++ showVersion cabalVersion ++ " of the Cabal library"
+       [ "diagrams-haddock v" ++ V.showVersion version ++ ", (c) 2013-2016 diagrams-haddock team (see LICENSE)"
+       , "compiled using version " ++ showCabalVersion cabalVersion ++ " of the Cabal library"
        , ""
        , "Compile inline diagrams code in Haddock documentation."
        , ""
@@ -133,7 +175,7 @@
       , "Either it does not exist or it is in the wrong format."
       , "* You may need to run 'cabal configure' first."
       , "* Make sure that the version of Cabal used to compile"
-      , "  diagrams-haddock (" ++ showVersion cabalVersion ++ ") matches the version used"
+      , "  diagrams-haddock (" ++ showCabalVersion cabalVersion ++ ") matches the version used"
       , "  by the cabal tool."
       , "* Use the -d option if you want diagrams-haddock to look in"
       , "  a different dist directory."
