diff --git a/doctest.cabal b/doctest.cabal
--- a/doctest.cabal
+++ b/doctest.cabal
@@ -1,5 +1,5 @@
 name:             doctest
-version:          0.10.0
+version:          0.10.1
 synopsis:         Test interactive Haskell examples
 description:      The doctest program checks examples in source code comments.
                   It is modeled after doctest for Python
diff --git a/src/Extract.hs b/src/Extract.hs
--- a/src/Extract.hs
+++ b/src/Extract.hs
@@ -3,7 +3,9 @@
 
 import           Prelude hiding (mod, concat)
 import           Control.Monad
+#if __GLASGOW_HASKELL__ < 710
 import           Control.Applicative
+#endif
 import           Control.Exception
 import           Data.List (partition, isSuffixOf)
 import           Data.Maybe
diff --git a/src/Interpreter.hs b/src/Interpreter.hs
--- a/src/Interpreter.hs
+++ b/src/Interpreter.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE CPP #-}
+
 module Interpreter (
   Interpreter
 , safeEval
@@ -12,7 +14,9 @@
 
 import           System.Process
 import           System.Directory (getPermissions, executable)
+#if __GLASGOW_HASKELL__ < 710
 import           Control.Applicative
+#endif
 import           Control.Monad
 import           Control.Exception hiding (handle)
 import           Data.Char
diff --git a/src/Parse.hs b/src/Parse.hs
--- a/src/Parse.hs
+++ b/src/Parse.hs
@@ -1,5 +1,6 @@
 {-# LANGUAGE PatternGuards #-}
 {-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE CPP #-}
 module Parse (
   Module (..)
 , DocTest (..)
@@ -20,8 +21,9 @@
 import           Data.List
 import           Data.Maybe
 import           Data.String
+#if __GLASGOW_HASKELL__ < 710
 import           Control.Applicative
-
+#endif
 import           Extract
 import           Location
 
diff --git a/src/Run.hs b/src/Run.hs
--- a/src/Run.hs
+++ b/src/Run.hs
@@ -5,12 +5,17 @@
 , doctest_
 , Summary
 , stripOptGhc
+, expandDirs
 #endif
 ) where
 
 import           Data.List
+import           Control.Applicative ((<$>))
 import           Control.Monad (when, unless)
+import           System.Directory (doesFileExist, doesDirectoryExist, getDirectoryContents)
+import           System.Environment (getEnvironment)
 import           System.Exit (exitFailure, exitSuccess)
+import           System.FilePath ((</>), takeExtension)
 import           System.IO
 
 import qualified Control.Exception as E
@@ -31,11 +36,15 @@
 --
 -- This can be used to create a Cabal test suite that runs doctest for your
 -- project.
+--
+-- If a directory is given, it is traversed to find all .hs and .lhs files
+-- inside of it, ignoring hidden entries.
 doctest :: [String] -> IO ()
-doctest args
-  | "--help"    `elem` args = putStr usage
-  | "--version" `elem` args = printVersion
+doctest args0
+  | "--help"    `elem` args0 = putStr usage
+  | "--version" `elem` args0 = printVersion
   | otherwise = do
+      args <- concat <$> mapM expandDirs args0
       i <- Interpreter.interpreterSupported
       unless i $ do
         hPutStrLn stderr "WARNING: GHC does not support --interactive, skipping tests"
@@ -48,8 +57,9 @@
 
       packageDBArgs <- getPackageDBArgs
       let addPackageConf = (packageDBArgs ++)
+      addDistArgs <- getAddDistArgs
 
-      r <- doctest_ (addPackageConf args_) `E.catch` \e -> do
+      r <- doctest_ (addDistArgs $ addPackageConf args_) `E.catch` \e -> do
         case fromException e of
           Just (UsageError err) -> do
             hPutStrLn stderr ("doctest: " ++ err)
@@ -57,6 +67,57 @@
             exitFailure
           _ -> E.throwIO e
       when (not $ isSuccess r) exitFailure
+
+-- | Expand a reference to a directory to all .hs and .lhs files within it.
+expandDirs :: String -> IO [String]
+expandDirs fp0 = do
+    isDir <- doesDirectoryExist fp0
+    if isDir
+        then findHaskellFiles fp0
+        else return [fp0]
+  where
+    findHaskellFiles dir = do
+        contents <- getDirectoryContents dir
+        concat <$> mapM go (filter (not . hidden) contents)
+      where
+        go name = do
+            isDir <- doesDirectoryExist fp
+            if isDir
+                then findHaskellFiles fp
+                else if isHaskellFile fp
+                        then return [fp]
+                        else return []
+          where
+            fp = dir </> name
+
+    hidden ('.':_) = True
+    hidden _ = False
+
+    isHaskellFile fp = takeExtension fp `elem` [".hs", ".lhs"]
+
+-- | Get the necessary arguments to add the @cabal_macros.h@ file and autogen
+-- directory, if present.
+getAddDistArgs :: IO ([String] -> [String])
+getAddDistArgs = do
+    env <- getEnvironment
+    let dist =
+            case lookup "HASKELL_DIST_DIR" env of
+                Nothing -> "dist"
+                Just x -> x
+        autogen = dist ++ "/build/autogen/"
+        cabalMacros = autogen ++ "cabal_macros.h"
+
+    dirExists <- doesDirectoryExist autogen
+    if dirExists
+        then do
+            fileExists <- doesFileExist cabalMacros
+            return $ \rest ->
+                  concat ["-i", dist, "/build/autogen/"]
+                : "-optP-include"
+                : (if fileExists
+                    then (concat ["-optP", dist, "/build/autogen/cabal_macros.h"]:)
+                    else id) rest
+        else return id
 
 isSuccess :: Summary -> Bool
 isSuccess s = sErrors s == 0 && sFailures s == 0
diff --git a/src/Runner.hs b/src/Runner.hs
--- a/src/Runner.hs
+++ b/src/Runner.hs
@@ -15,9 +15,9 @@
 
 #if __GLASGOW_HASKELL__ < 710
 import           Data.Monoid
+import           Control.Applicative
 #endif
 
-import           Control.Applicative
 import           Control.Monad hiding (forM_)
 import           Text.Printf (printf)
 import           System.IO (hPutStrLn, hPutStr, stderr, hIsTerminalDevice)
diff --git a/src/Sandbox.hs b/src/Sandbox.hs
--- a/src/Sandbox.hs
+++ b/src/Sandbox.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE BangPatterns #-}
+{-# LANGUAGE CPP, BangPatterns #-}
 
 module Sandbox
     ( getSandboxArguments
@@ -6,7 +6,9 @@
     , getSandboxConfigFile
     ) where
 
-import Control.Applicative ((<$>))
+#if __GLASGOW_HASKELL__ < 710
+import Data.Functor ((<$>))
+#endif
 import Control.Exception as E (catch, SomeException, throwIO)
 import Data.Char (isSpace)
 import Data.List (isPrefixOf, tails)
