summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlanZimmerman <>2019-08-28 18:45:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2019-08-28 18:45:00 (GMT)
commit72a92d78f15b002ee468a5d56182518a3d4f9b3e (patch)
tree1d4d4dd9139124049dbbaa917ae268fa4c5c2719
parent8b58806da36a60014c8441056e950947ed633c2c (diff)
version 0.6.2HEAD0.6.2master
-rwxr-xr-xChangeLog2
-rw-r--r--ghc-exactprint.cabal2
-rw-r--r--src/Language/Haskell/GHC/ExactPrint/Preprocess.hs16
-rwxr-xr-xtests/examples/ghc88/PersistUniqueTest.hs45
4 files changed, 19 insertions, 46 deletions
diff --git a/ChangeLog b/ChangeLog
index bb14784..430ab7e 100755
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,5 @@
+2019-08-28 v0.6.2
+ * Support GHC 8.8.1 (release candidate)
2019-05-27 v0.6.1
* Support GHC 8.8 (alpha1)
2019-03-01 v0.6
diff --git a/ghc-exactprint.cabal b/ghc-exactprint.cabal
index 9ab0a66..3c27c17 100644
--- a/ghc-exactprint.cabal
+++ b/ghc-exactprint.cabal
@@ -1,5 +1,5 @@
name: ghc-exactprint
-version: 0.6.1
+version: 0.6.2
synopsis: ExactPrint for GHC
description: Using the API Annotations available from GHC 7.10.2, this
library provides a means to round trip any code that can
diff --git a/src/Language/Haskell/GHC/ExactPrint/Preprocess.hs b/src/Language/Haskell/GHC/ExactPrint/Preprocess.hs
index 7731faa..07ec259 100644
--- a/src/Language/Haskell/GHC/ExactPrint/Preprocess.hs
+++ b/src/Language/Haskell/GHC/ExactPrint/Preprocess.hs
@@ -218,11 +218,27 @@ getPreprocessedSrcDirectPrim cppOptions src_fn = do
hsc_env <- GHC.getSession
let dfs = GHC.hsc_dflags hsc_env
new_env = hsc_env { GHC.hsc_dflags = injectCppOptions cppOptions dfs }
+#if __GLASGOW_HASKELL__ >= 808
+ -- (dflags', hspp_fn) <-
+ r <- GHC.liftIO $ GHC.preprocess new_env src_fn Nothing (Just (GHC.Cpp GHC.HsSrcFile))
+ case r of
+ Left err -> error $ showErrorMessages err
+ Right (dflags', hspp_fn) -> do
+ buf <- GHC.liftIO $ GHC.hGetStringBuffer hspp_fn
+ txt <- GHC.liftIO $ readFileGhc hspp_fn
+ return (txt, buf, dflags')
+#else
(dflags', hspp_fn) <-
GHC.liftIO $ GHC.preprocess new_env (src_fn, Just (GHC.Cpp GHC.HsSrcFile))
buf <- GHC.liftIO $ GHC.hGetStringBuffer hspp_fn
txt <- GHC.liftIO $ readFileGhc hspp_fn
return (txt, buf, dflags')
+#endif
+
+#if __GLASGOW_HASKELL__ >= 808
+showErrorMessages :: GHC.ErrorMessages -> String
+showErrorMessages msgs = intercalate "\n" $ map show $ GHC.bagToList msgs
+#endif
injectCppOptions :: CppOptions -> GHC.DynFlags -> GHC.DynFlags
injectCppOptions CppOptions{..} dflags =
diff --git a/tests/examples/ghc88/PersistUniqueTest.hs b/tests/examples/ghc88/PersistUniqueTest.hs
deleted file mode 100755
index 9a60a6d..0000000
--- a/tests/examples/ghc88/PersistUniqueTest.hs
+++ /dev/null
@@ -1,45 +0,0 @@
-{-# LANGUAGE QuasiQuotes, TemplateHaskell, CPP, GADTs, TypeFamilies, OverloadedStrings, FlexibleContexts, EmptyDataDecls, FlexibleInstances, GeneralizedNewtypeDeriving, MultiParamTypeClasses #-}
-module PersistUniqueTest where
-
-import Init
-
--- mpsGeneric = False is due to a bug or at least lack of a feature in mkKeyTypeDec TH.hs
-#if WITH_NOSQL
-mkPersist persistSettings { mpsGeneric = False } [persistUpperCase|
-#else
-share [mkPersist persistSettings { mpsGeneric = False }, mkMigrate "migration"] [persistLowerCase|
-#endif
- Fo
- foo Int
- bar Int
- Primary foo
- UniqueBar bar
- deriving Eq Show
-|]
-#ifdef WITH_NOSQL
-cleanDB :: (MonadIO m, PersistQuery backend, PersistEntityBackend Fo ~ backend) => ReaderT backend m ()
-cleanDB = do
- deleteWhere ([] :: [Filter Fo])
-
-db :: Action IO () -> Assertion
-db = db' cleanDB
-#endif
-
-specs :: Spec
-specs = describe "custom primary key" $ do
-#ifdef WITH_NOSQL
- return ()
-#else
- it "getBy" $ db $ do
- let b = 5
- k <- insert $ Fo 3 b
- Just vk <- get k
- Just vu <- getBy (UniqueBar b)
- vu @== Entity k vk
- it "insertUniqueEntity" $ db $ do
- let fo = Fo 3 5
- Just (Entity _ insertedFoValue) <- insertUniqueEntity fo
- Nothing <- insertUniqueEntity fo
- fo @== insertedFoValue
-#endif
-