diff --git a/doctest/DoctestDriver.hs b/doctest/DoctestDriver.hs
new file mode 100644
--- /dev/null
+++ b/doctest/DoctestDriver.hs
@@ -0,0 +1,12 @@
+{-# LANGUAGE CPP #-}
+
+#if MIN_VERSION_GLASGOW_HASKELL(8,4,4,0)
+{-# OPTIONS_GHC -F -pgmF doctest-discover #-}
+#else
+module Main where
+
+import qualified System.IO as IO
+
+main :: IO ()
+main = IO.putStrLn "WARNING: doctest will not run on GHC versions earlier than 8.4.4"
+#endif
diff --git a/hw-diagnostics.cabal b/hw-diagnostics.cabal
--- a/hw-diagnostics.cabal
+++ b/hw-diagnostics.cabal
@@ -1,33 +1,52 @@
-name:           hw-diagnostics
-version:        0.0.0.7
-synopsis:       Diagnostics library
-description:    Please see README.md
-category:       Profiling
-homepage:       http://github.com/haskell-works/hw-diagnostics#readme
-bug-reports:    https://github.com/haskell-works/hw-diagnostics/issues
-author:         John Ky
-maintainer:     newhoggy@gmail.com
-copyright:      2016 John Ky
-license:        BSD3
-license-file:   LICENSE
-build-type:     Simple
-cabal-version:  >= 1.10
-extra-source-files:
-    README.md
+cabal-version: 2.4
 
+name:                 hw-diagnostics
+version:              0.0.1.0
+synopsis:             Diagnostics library
+description:          Please see README.md
+category:             Profiling
+homepage:             http://github.com/haskell-works/hw-diagnostics#readme
+bug-reports:          https://github.com/haskell-works/hw-diagnostics/issues
+author:               John Ky
+maintainer:           newhoggy@gmail.com
+copyright:            2016-2019 John Ky
+license:              BSD-3-Clause
+license-file:         LICENSE
+tested-with:          GHC == 8.10.1, GHC == 8.8.3, GHC == 8.6.5, GHC == 8.4.4
+build-type:           Simple
+extra-source-files:   README.md
+
 source-repository head
   type: git
   location: https://github.com/haskell-works/hw-diagnostics
 
+common base                     { build-depends: base                     >= 4          && < 5      }
+
+common doctest                  { build-depends: doctest                  >= 0.16.2     && < 0.17   }
+common doctest-discover         { build-depends: doctest-discover         >= 0.2        && < 0.3    }
+
+common hw-diagnostics
+  build-depends:      hw-diagnostics
+
+common config
+  ghc-options:        -Wall
+  default-language:   Haskell2010
+
 library
-  exposed-modules:
-      HaskellWorks.Diagnostics
-      HaskellWorks.Diagnostics.Time
-  other-modules:
-      Paths_hw_diagnostics
-  hs-source-dirs:
-      src
-  ghc-options: -Wall
-  build-depends:
-      base >=4 && <5
-  default-language: Haskell2010
+  import:             base, config
+  exposed-modules:    HaskellWorks.Diagnostics
+                      HaskellWorks.Diagnostics.Time
+  other-modules:      Paths_hw_diagnostics
+  autogen-modules:    Paths_hw_diagnostics
+  hs-source-dirs:     src
+
+test-suite doctest
+  import:               base, config
+                      , doctest
+                      , doctest-discover
+                      , hw-diagnostics
+  type:                 exitcode-stdio-1.0
+  ghc-options:          -threaded
+  main-is:              DoctestDriver.hs
+  HS-Source-Dirs:       doctest
+  build-tool-depends:   doctest-discover:doctest-discover
