invariant 0.6.1 → 0.6.2
raw patch · 3 files changed
+61/−11 lines, 3 filesdep ~containersdep ~template-haskelldep ~th-abstraction
Dependency ranges changed: containers, template-haskell, th-abstraction
Files
- CHANGELOG.md +7/−0
- invariant.cabal +6/−6
- src/Data/Functor/Invariant/TH/Internal.hs +48/−5
CHANGELOG.md view
@@ -1,3 +1,10 @@+# 0.6.2 [2023.08.06]+* The Template Haskell machinery now uses `TemplateHaskellQuotes` when+ building with GHC 8.0+ instead of manually constructing each Template Haskell+ `Name`. A consequence of this is that `invariant` will now build with GHC+ 9.8, as `TemplateHaskellQuotes` abstracts over some internal Template Haskell+ changes introduced in 9.8.+ # 0.6.1 [2023.02.27] * Support `th-abstraction-0.5.*`.
invariant.cabal view
@@ -1,5 +1,5 @@ name: invariant-version: 0.6.1+version: 0.6.2 synopsis: Haskell98 invariant functors description: Haskell98 invariant functors (also known as exponential functors). .@@ -29,9 +29,9 @@ , GHC == 8.8.4 , GHC == 8.10.7 , GHC == 9.0.2- , GHC == 9.2.6- , GHC == 9.4.4- , GHC == 9.6.1+ , GHC == 9.2.7+ , GHC == 9.4.5+ , GHC == 9.6.2 extra-source-files: CHANGELOG.md, README.md source-repository head@@ -56,8 +56,8 @@ , StateVar >= 1.1 && < 2 , stm >= 2.2 && < 3 , tagged >= 0.7.3 && < 1- , template-haskell >= 2.4 && < 2.21- , th-abstraction >= 0.4 && < 0.6+ , template-haskell >= 2.4 && < 2.22+ , th-abstraction >= 0.4 && < 0.7 , transformers >= 0.2 && < 0.7 , transformers-compat >= 0.3 && < 1 , unordered-containers >= 0.2.4 && < 0.3
src/Data/Functor/Invariant/TH/Internal.hs view
@@ -1,5 +1,9 @@ {-# LANGUAGE CPP #-} +#if __GLASGOW_HASKELL__ >= 800+{-# LANGUAGE TemplateHaskellQuotes #-}+#endif+ {-| Module: Data.Functor.Invariant.TH.Internal Copyright: (C) 2012-2017 Nicolas Frisby, (C) 2015-2017 Ryan Scott@@ -24,9 +28,14 @@ import Language.Haskell.TH.Lib import Language.Haskell.TH.Syntax -#ifndef CURRENT_PACKAGE_KEY+#if __GLASGOW_HASKELL__ >= 800+import Data.Coerce (coerce)+import Data.Functor.Invariant (Invariant(..), Invariant2(..))+#else+# ifndef CURRENT_PACKAGE_KEY import Data.Version (showVersion) import Paths_invariant (version)+# endif #endif -------------------------------------------------------------------------------@@ -384,19 +393,52 @@ #endif ---------------------------------------------------------------------------------- Manually quoted names+-- Quoted names ------------------------------------------------------------------------------- +#if __GLASGOW_HASKELL__ >= 800+-- With GHC 8.0 or later, we can simply use TemplateHaskellQuotes to quote each+-- name. Life is good.++invariantTypeName :: Name+invariantTypeName = ''Invariant++invariant2TypeName :: Name+invariant2TypeName = ''Invariant2++invmapValName :: Name+invmapValName = 'invmap++invmap2ValName :: Name+invmap2ValName = 'invmap2++invmapConstValName :: Name+invmapConstValName = 'invmapConst++invmap2ConstValName :: Name+invmap2ConstValName = 'invmap2Const++coerceValName :: Name+coerceValName = 'coerce++errorValName :: Name+errorValName = 'error++seqValName :: Name+seqValName = 'seq+#else+-- On pre-8.0 GHCs, we do not have access to the TemplateHaskellQuotes+-- extension, so we construct the Template Haskell names by hand. -- By manually generating these names we avoid needing to use the -- TemplateHaskell language extension when compiling the invariant library. -- This allows the library to be used in stage1 cross-compilers. invariantPackageKey :: String-#ifdef CURRENT_PACKAGE_KEY+# ifdef CURRENT_PACKAGE_KEY invariantPackageKey = CURRENT_PACKAGE_KEY-#else+# else invariantPackageKey = "invariant-" ++ showVersion version-#endif+# endif mkInvariantName_tc :: String -> String -> Name mkInvariantName_tc = mkNameG_tc invariantPackageKey@@ -430,3 +472,4 @@ seqValName :: Name seqValName = mkNameG_v "ghc-prim" "GHC.Prim" "seq"+#endif