diff --git a/CHANGES.markdown b/CHANGES.markdown
--- a/CHANGES.markdown
+++ b/CHANGES.markdown
@@ -1,6 +1,14 @@
+## [v0.8.0.2](https://github.com/diagrams/diagrams-builder/tree/v0.8.0.2) (2018-01-21)
+
+- Allow `haskell-src-exts-1.20` and `haskell-src-exts-simple-1.20`
+- Bug fix for GHC 8.2: temp module generation now uses a valid name ([#32](https://github.com/diagrams/diagrams-builder/issues/32))
+
 ## [v0.8.0.1](https://github.com/diagrams/diagrams-builder/tree/v0.8.0.1) (2016-11-28)
 
 - Allow `haskell-src-exts-1.19` and `haskell-src-exts-simple-1.19`
+
+- Allow `hint-0.7` in Hackage revision 2.
+- Allow `base-4.10` in Hackage revision 3.
 
 ## [v0.8](https://github.com/diagrams/diagrams-builder/tree/v0.8) (2016-10-26)
 
diff --git a/diagrams-builder.cabal b/diagrams-builder.cabal
--- a/diagrams-builder.cabal
+++ b/diagrams-builder.cabal
@@ -1,5 +1,5 @@
 name:                diagrams-builder
-version:             0.8.0.1
+version:             0.8.0.2
 synopsis:            hint-based build service for the diagrams graphics EDSL.
 
 description:         @diagrams-builder@ provides backend-agnostic tools for
@@ -48,17 +48,17 @@
                        Diagrams.Builder.Opts
                        Diagrams.Builder.Modules
                        Diagrams.Builder.CmdLine
-  build-depends:       base >=4.2 && < 4.10,
-                       base-orphans >= 0.3 && < 0.6,
+  build-depends:       base >=4.2 && < 4.11,
+                       base-orphans >= 0.3 && < 0.7,
                        mtl >= 2.1 && < 2.3,
                        diagrams-lib >= 1.4 && < 1.5,
-                       hint >= 0.4 && < 0.7,
+                       hint >= 0.4 && < 0.8,
                        directory,
                        filepath,
                        transformers >= 0.3 && < 0.6,
                        split >= 0.2 && < 0.3,
-                       haskell-src-exts >= 1.18 && < 1.20,
-                       haskell-src-exts-simple >= 1.18 && < 1.20,
+                       haskell-src-exts >= 1.18 && < 1.21,
+                       haskell-src-exts-simple >= 1.18 && < 1.21,
                        cmdargs >= 0.6 && < 0.11,
                        lens >= 4.0 && < 4.16,
                        hashable >= 1.1 && < 1.3,
@@ -201,4 +201,5 @@
                        diagrams-pgf >= 1.4 && < 1.5,
                        bytestring >= 0.10.2 && < 0.11,
                        cmdargs >= 0.6 && < 0.11,
-                       lens >= 3.8 && < 4.16
+                       lens >= 3.8 && < 4.16,
+                       texrunner
diff --git a/src/Diagrams/Builder.hs b/src/Diagrams/Builder.hs
--- a/src/Diagrams/Builder.hs
+++ b/src/Diagrams/Builder.hs
@@ -48,6 +48,7 @@
 import           Control.Monad                       (guard, mplus, mzero)
 import           Control.Monad.Catch                 (MonadMask, catchAll)
 import           Control.Monad.Trans.Maybe           (MaybeT, runMaybeT)
+import           Data.Char                           (isAlphaNum)
 import           Data.Data
 import           Data.Hashable                       (Hashable (..))
 import           Data.List                           (foldl', nub)
@@ -97,7 +98,7 @@
 
 setDiagramImports m imps = do
     loadModules [m]
-    setTopLevelModules [takeBaseName m]
+    setTopLevelModules [takeWhile isAlphaNum $ takeBaseName m]
     setImportsQ $
       map (, Nothing)
         [ "Prelude"
@@ -208,7 +209,7 @@
         Just upd -> do
           tmpDir   <- getTemporaryDirectory
           (tmp, h) <- openTempFile tmpDir "Diagram.hs"
-          let m' = replaceModuleName (takeBaseName tmp) m
+          let m' = replaceModuleName (takeWhile isAlphaNum $ takeBaseName tmp) m
           hPutStr h (prettyPrint m')
           hClose h
 
diff --git a/src/tools/diagrams-builder-pgf.hs b/src/tools/diagrams-builder-pgf.hs
--- a/src/tools/diagrams-builder-pgf.hs
+++ b/src/tools/diagrams-builder-pgf.hs
@@ -1,17 +1,23 @@
 {-# LANGUAGE DeriveDataTypeable #-}
 {-# LANGUAGE RecordWildCards    #-}
+{-# LANGUAGE OverloadedStrings  #-}
 
 module Main where
 
 import qualified Data.ByteString.Builder     as BSB
-import qualified Data.ByteString.Lazy        as BSL
+import qualified Data.ByteString.Lazy.Char8  as BSL
+import qualified Data.ByteString.Char8       as BS
 import           Diagrams.Backend.PGF
 import           Diagrams.Backend.PGF.Render (Options (..))
 import           Diagrams.Builder
 import           Diagrams.Prelude            hiding (height, width)
 
 import           System.Directory            (copyFile,
-                                              createDirectoryIfMissing)
+                                              createDirectoryIfMissing,
+                                              getCurrentDirectory,
+                                              getDirectoryContents,
+                                              canonicalizePath)
+import System.Texrunner
 import qualified System.FilePath             as FP
 
 import           System.Console.CmdArgs      hiding (def)
@@ -22,6 +28,7 @@
       standalone = case ext of
                      ".pgf" -> False
                      ".tex" -> True
+                     ".pdf" -> True
                      _      -> False
   f   <- readFile srcFile
 
@@ -29,11 +36,17 @@
 
   let w = fmap realToFrac width :: Maybe Double
       h = fmap realToFrac height :: Maybe Double
+      hashedRegenerate' hash = do
+        let hashFile = hashToHexStr hash FP.<.> ext
+        files <- getDirectoryContents dir
+        case any (hashFile ==) files of
+            True  -> return Nothing
+            False -> return $ Just id
       bopts = mkBuildOpts PGF (zero :: V2 Double) (PGFOptions def (mkSizeSpec2D w h) False standalone)
                 & snippets .~ [f]
                 & imports  .~ [ "Diagrams.Backend.PGF" ]
                 & diaExpr  .~ expr
-                & decideRegen .~ (hashedRegenerate (\_ opts -> opts) dir)
+                & decideRegen .~ hashedRegenerate'
 
   res <- buildDiagram bopts
   case res of
@@ -41,9 +54,30 @@
     InterpErr ierr  -> putStrLn ("Error while compiling " ++ srcFile) >>
                        putStrLn (ppInterpError ierr)
     Skipped hash    -> copyFile (mkFile (hashToHexStr hash) ext) outFile
-    OK hash pgf -> let cached = mkFile (hashToHexStr hash) ext
-                   in do BSL.writeFile cached (BSB.toLazyByteString pgf)
-                         copyFile cached outFile
+    OK hash pgf -> do
+        let cached = mkFile (hashToHexStr hash) ext
+
+        case ext of
+            ".pdf" -> do
+                currentDir <- getCurrentDirectory
+                targetDir  <- canonicalizePath (FP.takeDirectory cached)
+
+                let source = BSB.toLazyByteString pgf
+
+                (_, texLog, mPDF) <- runTex (bopts^.backendOpts.surface.command)
+                                            (bopts^.backendOpts.surface.arguments)
+                                            [currentDir, targetDir]
+                                            source
+
+                case mPDF of
+                    Nothing  -> putStrLn "Error, no PDF found:"
+                            >> BS.putStrLn (prettyPrintLog texLog)
+                    Just pdf -> do BSL.writeFile cached pdf
+                                   copyFile cached outFile
+
+        -- tex output
+            _ -> do BSL.writeFile cached (BSB.toLazyByteString pgf)
+                    copyFile cached outFile
  where
   mkFile base ext = dir FP.</> base FP.<.> ext
 
