diff --git a/CHANGES.md b/CHANGES.md
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,3 +1,8 @@
+### 1.4.3.0
+
+- New tuple construction helpers `Data.Tuple.Utils.dup` and `Data.Tuple.Utils.triple`
+- Close sockets on connection failure in `connectTCPAddr` ([#50](https://github.com/haskell-hvr/missingh/issues/50))
+
 ### 1.4.2.1
 
 - GHC 7.0 only compat release
diff --git a/MissingH.cabal b/MissingH.cabal
--- a/MissingH.cabal
+++ b/MissingH.cabal
@@ -1,6 +1,6 @@
 cabal-version: 1.12
 name: MissingH
-version: 1.4.2.1
+version: 1.4.3.0
 
 build-type: Simple
 license: BSD3
@@ -36,6 +36,11 @@
   examples/test2.hs
   examples/test3.hs
 
+flag network--GE-3_0_0
+  description: [network](http://hackage.haskell.org/package/network) ≥ 3.0.0
+  default: True
+  manual: False
+
 source-repository head
   type: git
   location: https://github.com/hvr/missingh.git
@@ -101,28 +106,34 @@
     UndecidableInstances
   other-extensions:
     CPP
+    Safe
+    Trustworthy
     TypeSynonymInstances
 
   build-depends:
-      array               == 0.3.*
-    , base                == 4.3.*
-    , containers          == 0.4.*
-    , directory           == 1.1.*
-    , filepath            == 1.2.*
-    , hslogger            == 1.3.*
+      array               >= 0.4.0.0 && < 0.6
+    , base                >= 4.5.0.0 && < 4.15
+    , containers          >= 0.4.2.1 && < 0.7
+    , directory           >= 1.1.0.2 && < 1.4
+    , filepath            >= 1.3.0.0 && < 1.5
+    , hslogger            >= 1.3.0.0 && < 1.4
     , mtl                 >= 1.1.1.0 && < 2.3
     , old-locale          == 1.0.*
-    , old-time            == 1.0.*
+    , old-time            == 1.1.*
     , parsec              == 3.1.*   && (< 3.1.12 || >= 3.1.13)
-    , process             == 1.0.*
+    , process             >= 1.1.0.1 && < 1.7
     , random              >= 1.0.1.1 && < 1.2
     , regex-compat        >= 0.95.1  && < 0.96
-    , time                == 1.2.*
+    , time                >= 1.4     && < 1.10
 
-  build-depends: network >= 2.6.3.1 && <2.7
+  if flag(network--GE-3_0_0)
+    build-depends: network-bsd >= 2.8.1 && <2.9,
+                   network >= 3.0 && <3.2
+  else
+    build-depends: network >= 2.6.3.1 && <2.9
 
   If !os(windows)
-    Build-Depends: unix   >= 2.4.2 && < 2.5
+    Build-Depends: unix   >= 2.5.1.0 && < 2.8
 
   ghc-options: -fno-warn-deprecations
 
diff --git a/Setup.hs b/Setup.hs
deleted file mode 100644
--- a/Setup.hs
+++ /dev/null
@@ -1,2 +0,0 @@
-import Distribution.Simple
-main = defaultMain
diff --git a/src/Control/Concurrent/Thread/Utils.hs b/src/Control/Concurrent/Thread/Utils.hs
--- a/src/Control/Concurrent/Thread/Utils.hs
+++ b/src/Control/Concurrent/Thread/Utils.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE Safe #-}
 {- arch-tag: Thread utilities main file
 Copyright (c) 2004-2011 John Goerzen <jgoerzen@complete.org>
 
diff --git a/src/Data/BinPacking.hs b/src/Data/BinPacking.hs
--- a/src/Data/BinPacking.hs
+++ b/src/Data/BinPacking.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE Safe #-}
 {-
 Copyright (c) 2008-2011 John Goerzen <jgoerzen@complete.org>
 
diff --git a/src/Data/Bits/Utils.hs b/src/Data/Bits/Utils.hs
--- a/src/Data/Bits/Utils.hs
+++ b/src/Data/Bits/Utils.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE Safe #-}
 {- arch-tag: Bit utilities main file
 Copyright (c) 2004-2011 John Goerzen <jgoerzen@complete.org>
 
diff --git a/src/Data/CSV.hs b/src/Data/CSV.hs
--- a/src/Data/CSV.hs
+++ b/src/Data/CSV.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE Safe #-}
 {- arch-tag: CSV and TSV utilities
 Copyright (c) 2005-2011 John Goerzen <jgoerzen@complete.org>
 
diff --git a/src/Data/Compression/Inflate.hs b/src/Data/Compression/Inflate.hs
--- a/src/Data/Compression/Inflate.hs
+++ b/src/Data/Compression/Inflate.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE Safe #-}
 -- arch-tag: Inflate implementation for Haskell
 
 {-
diff --git a/src/Data/Either/Utils.hs b/src/Data/Either/Utils.hs
--- a/src/Data/Either/Utils.hs
+++ b/src/Data/Either/Utils.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE Safe #-}
 {- arch-tag: Either utilities
 Copyright (c) 2004-2011 John Goerzen <jgoerzen@complete.org>
 
diff --git a/src/Data/Hash/CRC32/GZip.hs b/src/Data/Hash/CRC32/GZip.hs
--- a/src/Data/Hash/CRC32/GZip.hs
+++ b/src/Data/Hash/CRC32/GZip.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE Safe #-}
 {- arch-tag: GZIP CRC32 implementation in pure Haskell
 Copyright (c) 2004-2011 John Goerzen <jgoerzen@complete.org>
 
diff --git a/src/Data/Hash/MD5.hs b/src/Data/Hash/MD5.hs
--- a/src/Data/Hash/MD5.hs
+++ b/src/Data/Hash/MD5.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE Safe #-}
+
 {-# OPTIONS_GHC -fno-warn-missing-methods #-}
 
 {- |
diff --git a/src/Data/Hash/MD5/Zord64_HARD.hs b/src/Data/Hash/MD5/Zord64_HARD.hs
--- a/src/Data/Hash/MD5/Zord64_HARD.hs
+++ b/src/Data/Hash/MD5/Zord64_HARD.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE Safe #-}
+
 {-# OPTIONS_HADDOCK hide #-}
 {-# OPTIONS_GHC -fno-warn-missing-methods #-}
 
diff --git a/src/Data/List/Utils.hs b/src/Data/List/Utils.hs
--- a/src/Data/List/Utils.hs
+++ b/src/Data/List/Utils.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE Safe #-}
 {- arch-tag: List utilities main file
 Copyright (c) 2004-2011 John Goerzen <jgoerzen@complete.org>
 
diff --git a/src/Data/MIME/Types.hs b/src/Data/MIME/Types.hs
--- a/src/Data/MIME/Types.hs
+++ b/src/Data/MIME/Types.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE Safe #-}
+
 {- arch-tag: MIME Types main file
 Copyright (c) 2004-2011 John Goerzen <jgoerzen@complete.org>
 
diff --git a/src/Data/Map/Utils.hs b/src/Data/Map/Utils.hs
--- a/src/Data/Map/Utils.hs
+++ b/src/Data/Map/Utils.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE Safe #-}
 {-
 Copyright (c) 2004-2011 John Goerzen <jgoerzen@complete.org>
 
diff --git a/src/Data/Maybe/Utils.hs b/src/Data/Maybe/Utils.hs
--- a/src/Data/Maybe/Utils.hs
+++ b/src/Data/Maybe/Utils.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE Safe #-}
 {- arch-tag: Maybe utilities
 Copyright (c) 2005-2011 John Goerzen <jgoerzen@complete.org>
 
diff --git a/src/Data/Progress/Meter.hs b/src/Data/Progress/Meter.hs
--- a/src/Data/Progress/Meter.hs
+++ b/src/Data/Progress/Meter.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE Safe #-}
+
 {-
 Copyright (c) 2006-2011 John Goerzen <jgoerzen@complete.org>
 
diff --git a/src/Data/Progress/Tracker.hs b/src/Data/Progress/Tracker.hs
--- a/src/Data/Progress/Tracker.hs
+++ b/src/Data/Progress/Tracker.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE Safe #-}
 {-
 Copyright (c) 2006-2011 John Goerzen <jgoerzen@complete.org>
 
diff --git a/src/Data/Quantity.hs b/src/Data/Quantity.hs
--- a/src/Data/Quantity.hs
+++ b/src/Data/Quantity.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE Safe #-}
 {-
 Copyright (c) 2006-2011 John Goerzen <jgoerzen@complete.org>
 
diff --git a/src/Data/String/Utils.hs b/src/Data/String/Utils.hs
--- a/src/Data/String/Utils.hs
+++ b/src/Data/String/Utils.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE Trustworthy #-}
+
 {- arch-tag: String utilities main file
 Copyright (c) 2004-2011 John Goerzen <jgoerzen@complete.org>
 
diff --git a/src/Data/Tuple/Utils.hs b/src/Data/Tuple/Utils.hs
--- a/src/Data/Tuple/Utils.hs
+++ b/src/Data/Tuple/Utils.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE Safe #-}
 {- arch-tag: Tuple utilities main file
 Copyright (c) 2004-2011 John Goerzen <jgoerzen@complete.org>
 
@@ -20,10 +21,23 @@
 -}
 
 module Data.Tuple.Utils(
+    -- * Construction
+    dup, triple,
     -- * Extraction
     fst3, snd3, thd3
     ) where
 
+-- | Construct a pair by duplication of a single value
+--
+-- @since 1.4.3.0
+dup :: a -> (a,a)
+dup a = (a,a)
+
+-- | Construct a 3-tuple from a single value
+--
+-- @since 1.4.3.0
+triple :: a -> (a,a,a)
+triple a = (a,a,a)
 
 -- | Take the first item out of a 3 element tuple
 fst3 :: (a,b,c) -> a
diff --git a/src/Network/Email/Mailbox.hs b/src/Network/Email/Mailbox.hs
--- a/src/Network/Email/Mailbox.hs
+++ b/src/Network/Email/Mailbox.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE Safe #-}
 {-
 Copyright (c) 2005-2011 John Goerzen <jgoerzen@complete.org>
 
diff --git a/src/Network/Email/Sendmail.hs b/src/Network/Email/Sendmail.hs
--- a/src/Network/Email/Sendmail.hs
+++ b/src/Network/Email/Sendmail.hs
@@ -1,4 +1,5 @@
 {-# LANGUAGE CPP #-}
+{-# LANGUAGE Safe #-}
 
 {- arch-tag: Sendmail utility
 Copyright (c) 2004-2011 John Goerzen <jgoerzen@complete.org>
diff --git a/src/Network/SocketServer.hs b/src/Network/SocketServer.hs
--- a/src/Network/SocketServer.hs
+++ b/src/Network/SocketServer.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE Trustworthy #-}
+
 {- arch-tag: Generic Server Support
 Copyright (c) 2004-2011 John Goerzen <jgoerzen@complete.org>
 
diff --git a/src/Network/Utils.hs b/src/Network/Utils.hs
--- a/src/Network/Utils.hs
+++ b/src/Network/Utils.hs
@@ -1,4 +1,5 @@
 {-# LANGUAGE CPP #-}
+{-# LANGUAGE Trustworthy #-}
 
 {- arch-tag: Network utilities main file
 Copyright (c) 2004-2011 John Goerzen <jgoerzen@complete.org>
@@ -31,6 +32,7 @@
 #if !(defined(mingw32_HOST_OS) || defined(mingw32_TARGET_OS) || defined(__MINGW32__))
 import qualified System.Posix.Signals
 #endif
+import           Control.Exception (bracketOnError)
 
 {- | Sets up the system for networking.  Similar to the built-in
 withSocketsDo (and actually, calls it), but also sets the SIGPIPE
@@ -62,9 +64,8 @@
 connectTCPAddr :: SockAddr -> IO Socket
 connectTCPAddr addr = do
                       proto <- getProtocolNumber "tcp"
-                      s <- socket AF_INET Stream proto
-                      connect s addr
-                      return s
+                      bracketOnError (socket AF_INET Stream proto) close
+                        (\s -> connect s addr >> return s)
 
 listenTCPAddr :: SockAddr -> Int -> IO Socket
 listenTCPAddr addr queuelen = do
diff --git a/src/System/Cmd/Utils.hs b/src/System/Cmd/Utils.hs
--- a/src/System/Cmd/Utils.hs
+++ b/src/System/Cmd/Utils.hs
@@ -1,5 +1,6 @@
 -- arch-tag: Command utilities main file
 {-# LANGUAGE CPP #-}
+{-# LANGUAGE Trustworthy #-}
 
 {-
 Copyright (c) 2004-2011 John Goerzen <jgoerzen@complete.org>
@@ -325,7 +326,11 @@
                 Just (Exited (ExitSuccess)) -> return ()
                 Just (Exited (ExitFailure fc)) ->
                     cmdfailed funcname fp args fc
+#if MIN_VERSION_unix(2,7,0)
+                Just (Terminated sig _) ->
+#else
                 Just (Terminated sig) ->
+#endif
                     warnfail fp args $ "Terminated by signal " ++ show sig
                 Just (Stopped sig) ->
                     warnfail fp args $ "Stopped by signal " ++ show sig
@@ -351,7 +356,11 @@
        case ec of
             Exited ExitSuccess -> return ()
             Exited (ExitFailure fc) -> cmdfailed "safeSystem" command args fc
+#if MIN_VERSION_unix(2,7,0)
+            Terminated s _ -> cmdsignalled "safeSystem" command args s
+#else
             Terminated s -> cmdsignalled "safeSystem" command args s
+#endif
             Stopped s -> cmdsignalled "safeSystem" command args s
 #endif
 
diff --git a/src/System/Console/GetOpt/Utils.hs b/src/System/Console/GetOpt/Utils.hs
--- a/src/System/Console/GetOpt/Utils.hs
+++ b/src/System/Console/GetOpt/Utils.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE Safe #-}
 {-
 Copyright (c) 2005-2011 John Goerzen <jgoerzen@complete.org>
 
diff --git a/src/System/Daemon.hs b/src/System/Daemon.hs
--- a/src/System/Daemon.hs
+++ b/src/System/Daemon.hs
@@ -1,4 +1,5 @@
 {-# LANGUAGE CPP #-}
+{-# LANGUAGE Trustworthy #-}
 
 {-
 Copyright (c) 2005-2011 John Goerzen <jgoerzen@complete.org>
diff --git a/src/System/Debian/ControlParser.hs b/src/System/Debian/ControlParser.hs
--- a/src/System/Debian/ControlParser.hs
+++ b/src/System/Debian/ControlParser.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE Safe #-}
+
 {- arch-tag: Parser for Debian control file
 Copyright (c) 2004-2011 John Goerzen <jgoerzen@complete.org>
 
diff --git a/src/System/FileArchive/GZip.hs b/src/System/FileArchive/GZip.hs
--- a/src/System/FileArchive/GZip.hs
+++ b/src/System/FileArchive/GZip.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE Safe #-}
 {- arch-tag: GZip file support in Haskell
 Copyright (c) 2004-2011 John Goerzen <jgoerzen@complete.org>
 
diff --git a/src/System/IO/Binary.hs b/src/System/IO/Binary.hs
--- a/src/System/IO/Binary.hs
+++ b/src/System/IO/Binary.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE Trustworthy #-}
+
 {- arch-tag: I/O utilities, binary tools
 Copyright (c) 2004-2011 John Goerzen <jgoerzen@complete.org>
 
diff --git a/src/System/IO/HVFS.hs b/src/System/IO/HVFS.hs
--- a/src/System/IO/HVFS.hs
+++ b/src/System/IO/HVFS.hs
@@ -1,4 +1,5 @@
 {-# LANGUAGE CPP, TypeSynonymInstances #-}
+{-# LANGUAGE Trustworthy #-}
 {- arch-tag: HVFS main file
 Copyright (c) 2004-2011 John Goerzen <jgoerzen@complete.org>
 
@@ -61,6 +62,10 @@
 import System.Time
 import qualified System.Directory as D
 
+#if MIN_VERSION_directory(1,2,0)
+import Data.Time.Clock.POSIX ( utcTimeToPOSIXSeconds )
+#endif
+
 {- | Encapsulate a 'HVFSStat' result.  This is required due to Haskell
 typing restrictions.  You can get at it with:
 
@@ -304,7 +309,11 @@
     vGetSymbolicLinkStatus = vGetFileStatus
 #endif
 
+#if MIN_VERSION_directory(1,2,0)
+    vGetModificationTime _ p = D.getModificationTime p >>= (\modUTCTime -> return $ TOD ((toEnum . fromEnum . utcTimeToPOSIXSeconds) modUTCTime) 0)
+#else
     vGetModificationTime _ = D.getModificationTime
+#endif
 #if !(defined(mingw32_HOST_OS) || defined(mingw32_TARGET_OS) || defined(__MINGW32__))
     vCreateSymbolicLink _ = createSymbolicLink
     vReadSymbolicLink _ = readSymbolicLink
diff --git a/src/System/IO/HVFS/Combinators.hs b/src/System/IO/HVFS/Combinators.hs
--- a/src/System/IO/HVFS/Combinators.hs
+++ b/src/System/IO/HVFS/Combinators.hs
@@ -1,5 +1,5 @@
 {-# LANGUAGE CPP #-}
-
+{-# LANGUAGE Safe #-}
 {- arch-tag: HVFS Combinators
 Copyright (c) 2004-2011 John Goerzen <jgoerzen@complete.org>
 
diff --git a/src/System/IO/HVFS/InstanceHelpers.hs b/src/System/IO/HVFS/InstanceHelpers.hs
--- a/src/System/IO/HVFS/InstanceHelpers.hs
+++ b/src/System/IO/HVFS/InstanceHelpers.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE Safe #-}
 {- arch-tag: HVFS instance helpers
 Copyright (c) 2004-2011 John Goerzen <jgoerzen@complete.org>
 
diff --git a/src/System/IO/HVFS/Utils.hs b/src/System/IO/HVFS/Utils.hs
--- a/src/System/IO/HVFS/Utils.hs
+++ b/src/System/IO/HVFS/Utils.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE Trustworthy #-}
 
 {- arch-tag: HVFS utilities main file
 Copyright (c) 2004-2011 John Goerzen <jgoerzen@complete.org>
diff --git a/src/System/IO/HVIO.hs b/src/System/IO/HVIO.hs
--- a/src/System/IO/HVIO.hs
+++ b/src/System/IO/HVIO.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE Safe #-}
+
 {- arch-tag: HVIO main file
 Copyright (c) 2004-2011 John Goerzen <jgoerzen@complete.org>
 
diff --git a/src/System/IO/PlafCompat.hs b/src/System/IO/PlafCompat.hs
--- a/src/System/IO/PlafCompat.hs
+++ b/src/System/IO/PlafCompat.hs
@@ -1,4 +1,5 @@
 {-# LANGUAGE CPP  #-}
+{-# LANGUAGE Safe #-}
 {- Platform Compatibility Layer
 Copyright (c) 2005-2011 John Goerzen <jgoerzen@complete.org>
 
diff --git a/src/System/IO/StatCompat.hs b/src/System/IO/StatCompat.hs
--- a/src/System/IO/StatCompat.hs
+++ b/src/System/IO/StatCompat.hs
@@ -1,4 +1,5 @@
 {-# LANGUAGE CPP  #-}
+{-# LANGUAGE Safe #-}
 {-
 Copyright (c) 2005-2011 John Goerzen <jgoerzen@complete.org>
 
diff --git a/src/System/IO/Utils.hs b/src/System/IO/Utils.hs
--- a/src/System/IO/Utils.hs
+++ b/src/System/IO/Utils.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE Trustworthy #-}
+
 {-
 Copyright (c) 2004-2011 John Goerzen <jgoerzen@complete.org>
 
diff --git a/src/System/IO/WindowsCompat.hs b/src/System/IO/WindowsCompat.hs
--- a/src/System/IO/WindowsCompat.hs
+++ b/src/System/IO/WindowsCompat.hs
@@ -1,5 +1,5 @@
 {-# LANGUAGE CPP #-}
-
+{-# LANGUAGE Safe #-}
 {- Windows compatibility layer
 Copyright (c) 2005-2011 John Goerzen <jgoerzen@complete.org>
 
@@ -125,7 +125,11 @@
        isdir <- doesDirectoryExist fp
        perms <- getPermissions fp
        modct <- getModificationTime fp
+#if MIN_VERSION_directory(1,2,0)
+       let epochtime = utcTimeToSeconds modct
+#else
        let epochtime = clockTimeToEpoch modct
+#endif
        return $ FileStatusCompat {deviceID = -1,
                                   fileID = -1,
                                   fileMode = if isfile then regularFileMode
diff --git a/src/System/Path.hs b/src/System/Path.hs
--- a/src/System/Path.hs
+++ b/src/System/Path.hs
@@ -1,4 +1,5 @@
 {-# LANGUAGE CPP #-}
+{-# LANGUAGE Safe #-}
 {- arch-tag: Path utilities main file
 Copyright (C) 2004-2011 John Goerzen <jgoerzen@complete.org>
 
diff --git a/src/System/Path/Glob.hs b/src/System/Path/Glob.hs
--- a/src/System/Path/Glob.hs
+++ b/src/System/Path/Glob.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE Safe #-}
+
 {-
 Copyright (c) 2006-2011 John Goerzen <jgoerzen@complete.org>
 
diff --git a/src/System/Path/NameManip.hs b/src/System/Path/NameManip.hs
--- a/src/System/Path/NameManip.hs
+++ b/src/System/Path/NameManip.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE Safe #-}
 {- |
    Module     : System.Path.NameManip
    Copyright  : Copyright (C) 2004 Volker Wysk
diff --git a/src/System/Path/WildMatch.hs b/src/System/Path/WildMatch.hs
--- a/src/System/Path/WildMatch.hs
+++ b/src/System/Path/WildMatch.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE Trustworthy #-}
+
 {-
 Copyright (c) 2006-2011 John Goerzen <jgoerzen@complete.org>
 
diff --git a/src/System/Posix/Consts.hs b/src/System/Posix/Consts.hs
--- a/src/System/Posix/Consts.hs
+++ b/src/System/Posix/Consts.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE Safe #-}
 {- Posix consts not included with Haskell
 Copyright (c) 2005-2011 John Goerzen <jgoerzen@complete.org>
 
diff --git a/src/System/Time/Utils.hs b/src/System/Time/Utils.hs
--- a/src/System/Time/Utils.hs
+++ b/src/System/Time/Utils.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE Safe #-}
 {- arch-tag: Time utilities main file
 Copyright (c) 2004-2011 John Goerzen <jgoerzen@complete.org>
 
diff --git a/src/Text/ParserCombinators/Parsec/Utils.hs b/src/Text/ParserCombinators/Parsec/Utils.hs
--- a/src/Text/ParserCombinators/Parsec/Utils.hs
+++ b/src/Text/ParserCombinators/Parsec/Utils.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE Safe #-}
 {- arch-tag: Parsec utilities
 Copyright (c) 2004-2011 John Goerzen <jgoerzen@complete.org>
 
diff --git a/testsrc/TestUtils.hs b/testsrc/TestUtils.hs
--- a/testsrc/TestUtils.hs
+++ b/testsrc/TestUtils.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE CPP #-}
+
 module TestUtils (mapassertEqual, assertRaises, errorCallMsg) where
 
 import           Control.Exception (ErrorCall (..), Exception,
@@ -27,3 +29,6 @@
 
 errorCallMsg :: ErrorCall -> String
 errorCallMsg (ErrorCall msg)               = msg
+#if MIN_VERSION_base(4,9,0)
+errorCallMsg (ErrorCallWithLocation msg _) = msg
+#endif
