diff --git a/.travis.yml b/.travis.yml
--- a/.travis.yml
+++ b/.travis.yml
@@ -27,6 +27,9 @@
     - env: CABALVER=1.24 GHCVER=8.0.2
       compiler: ": #GHC 8.0.2"
       addons: {apt: {packages: [cabal-install-1.24,ghc-8.0.2,alex-3.1.4,happy-1.19.5], sources: [hvr-ghc]}}
+    - env: CABALVER=1.24 GHCVER=8.2.1
+      compiler: ": #GHC 8.2.1"
+      addons: {apt: {packages: [cabal-install-1.24,ghc-8.2.1,alex-3.1.4,happy-1.19.5], sources: [hvr-ghc]}}
 
 before_install:
  - unset CC
diff --git a/CHANGELOG.markdown b/CHANGELOG.markdown
--- a/CHANGELOG.markdown
+++ b/CHANGELOG.markdown
@@ -1,3 +1,15 @@
+1.7
+---
+* Make `trifecta` forward `-Wcompat`ible:
+  * Adding `Semigroup` instances to correspond to every existing `Monoid`
+    instance. This requires adding a `Semigroup` constraint to the `Monoid`
+    instance for `Parser` to emulate the `Semigroup`-`Monoid` superclass
+    relation that will be present in future versions of GHC.
+  * Adding a `MonadFail` instance for `Parser`
+* Revamp `Setup.hs` to use `cabal-doctest`. This makes it build
+  with `Cabal-2.0`, and makes the `doctest`s work with `cabal new-build` and
+  sandboxes.
+
 1.6.2.1
 -------
 * Add this changelog to the `extra-souce-files` in `trifecta.cabal` so that the
diff --git a/Setup.lhs b/Setup.lhs
--- a/Setup.lhs
+++ b/Setup.lhs
@@ -1,44 +1,34 @@
-#!/usr/bin/runhaskell
 \begin{code}
+{-# LANGUAGE CPP #-}
 {-# OPTIONS_GHC -Wall #-}
 module Main (main) where
 
-import Data.List ( nub )
-import Data.Version ( showVersion )
-import Distribution.Package ( PackageName(PackageName), PackageId, InstalledPackageId, packageVersion, packageName )
-import Distribution.PackageDescription ( PackageDescription(), TestSuite(..) )
-import Distribution.Simple ( defaultMainWithHooks, UserHooks(..), simpleUserHooks )
-import Distribution.Simple.Utils ( rewriteFile, createDirectoryIfMissingVerbose )
-import Distribution.Simple.BuildPaths ( autogenModulesDir )
-import Distribution.Simple.Setup ( BuildFlags(buildVerbosity), fromFlag )
-import Distribution.Simple.LocalBuildInfo ( withLibLBI, withTestLBI, LocalBuildInfo(), ComponentLocalBuildInfo(componentPackageDeps) )
-import Distribution.Verbosity ( Verbosity )
-import System.FilePath ( (</>) )
+#ifndef MIN_VERSION_cabal_doctest
+#define MIN_VERSION_cabal_doctest(x,y,z) 0
+#endif
 
+#if MIN_VERSION_cabal_doctest(1,0,0)
+
+import Distribution.Extra.Doctest ( defaultMainWithDoctests )
 main :: IO ()
-main = defaultMainWithHooks simpleUserHooks
-  { buildHook = \pkg lbi hooks flags -> do
-     generateBuildModule (fromFlag (buildVerbosity flags)) pkg lbi
-     buildHook simpleUserHooks pkg lbi hooks flags
-  }
+main = defaultMainWithDoctests "doctests"
 
-generateBuildModule :: Verbosity -> PackageDescription -> LocalBuildInfo -> IO ()
-generateBuildModule verbosity pkg lbi = do
-  let dir = autogenModulesDir lbi
-  createDirectoryIfMissingVerbose verbosity True dir
-  withLibLBI pkg lbi $ \_ libcfg -> do
-    withTestLBI pkg lbi $ \suite suitecfg -> do
-      rewriteFile (dir </> "Build_" ++ testName suite ++ ".hs") $ unlines
-        [ "module Build_" ++ testName suite ++ " where"
-        , "deps :: [String]"
-        , "deps = " ++ (show $ formatdeps (testDeps libcfg suitecfg))
-        ]
-  where
-    formatdeps = map (formatone . snd)
-    formatone p = case packageName p of
-      PackageName n -> n ++ "-" ++ showVersion (packageVersion p)
+#else
 
-testDeps :: ComponentLocalBuildInfo -> ComponentLocalBuildInfo -> [(InstalledPackageId, PackageId)]
-testDeps xs ys = nub $ componentPackageDeps xs ++ componentPackageDeps ys
+#ifdef MIN_VERSION_Cabal
+-- If the macro is defined, we have new cabal-install,
+-- but for some reason we don't have cabal-doctest in package-db
+--
+-- Probably we are running cabal sdist, when otherwise using new-build
+-- workflow
+import Warning ()
+#endif
+
+import Distribution.Simple
+
+main :: IO ()
+main = defaultMain
+
+#endif
 
 \end{code}
diff --git a/Warning.hs b/Warning.hs
new file mode 100644
--- /dev/null
+++ b/Warning.hs
@@ -0,0 +1,5 @@
+module Warning
+  {-# WARNING ["You are configuring this package without cabal-doctest installed.",
+               "The doctests test-suite will not work as a result.",
+               "To fix this, install cabal-doctest before configuring."] #-}
+  () where
diff --git a/src/Text/Trifecta/Parser.hs b/src/Text/Trifecta/Parser.hs
--- a/src/Text/Trifecta/Parser.hs
+++ b/src/Text/Trifecta/Parser.hs
@@ -39,6 +39,7 @@
 import Control.Applicative as Alternative
 import Control.Monad (MonadPlus(..), ap, join)
 import Control.Monad.IO.Class
+import qualified Control.Monad.Fail as Fail
 import Data.ByteString as Strict hiding (empty, snoc)
 import Data.ByteString.UTF8 as UTF8
 import Data.Maybe (isJust)
@@ -129,14 +130,15 @@
   (<>) = liftA2 (<>)
   {-# INLINE (<>) #-}
 
-instance Monoid a => Monoid (Parser a) where
-  mappend = liftA2 mappend
+instance (Semigroup a, Monoid a) => Monoid (Parser a) where
+  mappend = (<>)
   {-# INLINE mappend #-}
+
   mempty = pure mempty
   {-# INLINE mempty #-}
 
 instance Monad Parser where
-  return a = Parser $ \ eo _ _ _ _ _ -> eo a mempty
+  return = pure
   {-# INLINE return #-}
   Parser m >>= k = Parser $ \ eo ee co ce d bs ->
     m -- epsilon result: feed result to monadic continutaion; committed
@@ -170,6 +172,10 @@
   {-# INLINE (>>=) #-}
   (>>) = (*>)
   {-# INLINE (>>) #-}
+  fail = Fail.fail
+  {-# INLINE fail #-}
+
+instance Fail.MonadFail Parser where
   fail s = Parser $ \ _ ee _ _ _ _ -> ee (failed s)
   {-# INLINE fail #-}
 
diff --git a/src/Text/Trifecta/Result.hs b/src/Text/Trifecta/Result.hs
--- a/src/Text/Trifecta/Result.hs
+++ b/src/Text/Trifecta/Result.hs
@@ -100,7 +100,10 @@
 
 instance Monoid ErrInfo where
   mempty = ErrInfo mempty mempty
-  mappend (ErrInfo xs d1) (ErrInfo ys d2) = ErrInfo (vsep [xs, ys]) (max d1 d2)
+  mappend = (<>)
+
+instance Semigroup ErrInfo where
+  ErrInfo xs d1 <> ErrInfo ys d2 = ErrInfo (vsep [xs, ys]) (max d1 d2)
 
 -- | The result of parsing. Either we succeeded or something went wrong.
 data Result a
diff --git a/src/Text/Trifecta/Util/IntervalMap.hs b/src/Text/Trifecta/Util/IntervalMap.hs
--- a/src/Text/Trifecta/Util/IntervalMap.hs
+++ b/src/Text/Trifecta/Util/IntervalMap.hs
@@ -129,9 +129,12 @@
 
 instance Ord v => Monoid (IntInterval v) where
   mempty = NoInterval
-  NoInterval `mappend` i  = i
-  i `mappend` NoInterval  = i
-  IntInterval _ hi1 `mappend` IntInterval int2 hi2 =
+  mappend = (<>)
+
+instance Ord v => Semigroup (IntInterval v) where
+  NoInterval <> i  = i
+  i <> NoInterval  = i
+  IntInterval _ hi1 <> IntInterval int2 hi2 =
     IntInterval int2 (max hi1 hi2)
 
 instance Ord v => Measured (IntInterval v) (Node v a) where
@@ -194,7 +197,10 @@
 
 instance Ord v => Monoid (IntervalMap v a) where
   mempty = empty
-  mappend = union
+  mappend = (<>)
+
+instance Ord v => Semigroup (IntervalMap v a) where
+  (<>) = union
 
 -- | /O(n)/. Add a delta to each interval in the map
 offset :: (Ord v, Monoid v) => v -> IntervalMap v a -> IntervalMap v a
diff --git a/src/Text/Trifecta/Util/It.hs b/src/Text/Trifecta/Util/It.hs
--- a/src/Text/Trifecta/Util/It.hs
+++ b/src/Text/Trifecta/Util/It.hs
@@ -77,7 +77,7 @@
 simplifyIt pa _       = pa
 
 instance Monad (It r) where
-  return = Pure
+  return = pure
   Pure a >>= f = f a
   It a k >>= f = It (extract (f a)) $ \r -> case k r of
     It a' k' -> It (indexIt (f a') r) $ k' >=> f
diff --git a/tests/doctests.hs b/tests/doctests.hs
--- a/tests/doctests.hs
+++ b/tests/doctests.hs
@@ -1,34 +1,25 @@
-{-# LANGUAGE CPP #-}
+-----------------------------------------------------------------------------
+-- |
+-- Module      :  Main (doctests)
+-- Copyright   :  (C) 2012-14 Edward Kmett
+-- License     :  BSD-style (see the file LICENSE)
+-- Maintainer  :  Edward Kmett <ekmett@gmail.com>
+-- Stability   :  provisional
+-- Portability :  portable
+--
+-- This module provides doctests for a project based on the actual versions
+-- of the packages it was built with. It requires a corresponding Setup.lhs
+-- to be added to the project
+-----------------------------------------------------------------------------
 module Main where
 
-import Build_doctests (deps)
-#if __GLASGOW_HASKELL__ < 710
-import Control.Applicative
-#endif
-import Control.Monad
-import Data.List
-import System.Directory
-import System.FilePath
+import Build_doctests (flags, pkgs, module_sources)
+import Data.Foldable (traverse_)
 import Test.DocTest
 
 main :: IO ()
-main = getSources >>= \sources -> doctest $
-    "-isrc"
-  : "-idist/build/autogen"
-  : "-optP-include"
-  : "-fobject-code"
-  : "-optPdist/build/autogen/cabal_macros.h"
-  : "-hide-all-packages"
-  : map ("-package="++) deps ++ sources
-
-getSources :: IO [FilePath]
-getSources = filter (isSuffixOf ".hs") <$> go "src"
+main = do
+    traverse_ putStrLn args
+    doctest args
   where
-    go dir = do
-      (dirs, files) <- getFilesAndDirectories dir
-      (files ++) . concat <$> mapM go dirs
-
-getFilesAndDirectories :: FilePath -> IO ([FilePath], [FilePath])
-getFilesAndDirectories dir = do
-  c <- map (dir </>) . filter (`notElem` ["..", "."]) <$> getDirectoryContents dir
-  (,) <$> filterM doesDirectoryExist c <*> filterM doesFileExist c
+    args = flags ++ pkgs ++ module_sources
diff --git a/trifecta.cabal b/trifecta.cabal
--- a/trifecta.cabal
+++ b/trifecta.cabal
@@ -1,6 +1,6 @@
 name:          trifecta
 category:      Text, Parsing, Diagnostics, Pretty Printer, Logging
-version:       1.6.2.1
+version:       1.7
 license:       BSD3
 cabal-version: >= 1.10
 license-file:  LICENSE
@@ -22,11 +22,18 @@
   .travis.yml
   CHANGELOG.markdown
   README.markdown
+  Warning.hs
 
 source-repository head
   type: git
   location: https://github.com/ekmett/trifecta
 
+custom-setup
+  setup-depends:
+    base          >= 4 && < 5,
+    Cabal,
+    cabal-doctest >= 1 && < 1.1
+
 library
   exposed-modules:
     Text.Trifecta
@@ -75,6 +82,11 @@
   hs-source-dirs:   src
   ghc-options:      -O2 -Wall -fobject-code
 
+  -- See https://ghc.haskell.org/trac/ghc/wiki/Migration/8.0#base-4.9.0.0
+  if impl(ghc >= 8.0)
+    ghc-options: -Wcompat -Wnoncanonical-monad-instances -Wnoncanonical-monadfail-instances
+  else
+    build-depends: fail == 4.9.*
 
 test-suite doctests
   type:             exitcode-stdio-1.0
@@ -84,9 +96,7 @@
   default-language: Haskell2010
   build-depends:
     base,
-    directory >= 1.0,
-    doctest   >= 0.9.1,
-    filepath
+    doctest >= 0.11.1 && < 0.12
 
 test-suite quickcheck
   type:    exitcode-stdio-1.0
