vector-th-unbox 0.2.1.9 → 0.2.2
raw patch · 3 files changed
+24/−45 lines, 3 filesdep ~basedep ~template-haskelldep ~vectorPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base, template-haskell, vector
API changes (from Hackage documentation)
Files
- CHANGELOG.md +5/−0
- Data/Vector/Unboxed/Deriving.hs +15/−40
- vector-th-unbox.cabal +4/−5
CHANGELOG.md view
@@ -1,3 +1,8 @@+## 0.2.2++* Fixed the build failure on GHC 9.2+* Dropped the support for GHC older than 8.0+ ## 0.2.1.9 * Fixed the build failure on GHC 7.10.3 (and older)
Data/Vector/Unboxed/Deriving.hs view
@@ -1,14 +1,8 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE RecordWildCards #-}-#if __GLASGOW_HASKELL__ >= 800 {-# LANGUAGE TemplateHaskellQuotes #-}-#else-{-# LANGUAGE TemplateHaskell #-}-#endif-#if __GLASGOW_HASKELL__ >= 702 {-# LANGUAGE Trustworthy #-}-#endif {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE ViewPatterns #-} {-# OPTIONS -Wall #-}@@ -27,9 +21,6 @@ derivingUnbox ) where -#if !MIN_VERSION_base(4,8,0)-import Control.Applicative-#endif import Control.Arrow import Control.Monad import Data.Char (isAlphaNum)@@ -56,18 +47,16 @@ let vName = mkName ("V_" ++ name) i <- newPatExp "idx" n <- newPatExp "len"- mv <- first (ConP mvName . (:[])) <$> newPatExp "mvec"- mv' <- first (ConP mvName . (:[])) <$> newPatExp "mvec'"- v <- first (ConP vName . (:[])) <$> newPatExp "vec"+ mv <- first (conPCompat mvName . (:[])) <$> newPatExp "mvec"+ mv' <- first (conPCompat mvName . (:[])) <$> newPatExp "mvec'"+ v <- first (conPCompat vName . (:[])) <$> newPatExp "vec" return Common {..}---- Turn any 'Name' into a capturable one.-capture :: Name -> Name-#if __GLASGOW_HASKELL__ == 704-capture = mkName . nameBase-#else-capture = id+ where+ conPCompat n pats = ConP n+#if MIN_VERSION_template_haskell(2,18,0)+ [] #endif+ pats liftE :: Exp -> Exp -> Exp liftE e = InfixE (Just e) (VarE 'liftM) . Just@@ -77,14 +66,9 @@ -- A final coercion (@Exp → Exp@) is applied to the body of the function. -- Complimentary @INLINE@ pragma included. wrap :: Name -> [(Pat, Exp)] -> (Exp -> Exp) -> [Dec]-wrap fun (unzip -> (pats, exps)) coerce = [inline, method] where- name = capture fun-#if MIN_VERSION_template_haskell(2,8,0)+wrap name (unzip -> (pats, exps)) coerce = [inline, method] where inline = PragmaD (InlineP name Inline FunLike AllPhases)-#else- inline = PragmaD ( InlineP name (InlineSpec True False Nothing) )-#endif- body = coerce $ foldl AppE (VarE fun) exps+ body = coerce $ foldl AppE (VarE name) exps method = FunD name [Clause pats (NormalB body) []] {-| Let's consider a more complex example: suppose we want an @Unbox@@@ -117,17 +101,11 @@ _ -> fail "Expecting a type of the form: cxts => typ -> rep" let s = VarT (mkName "s")-#if MIN_VERSION_template_haskell(2,11,0) let lazy = Bang NoSourceUnpackedness NoSourceStrictness-# define MAYBE_OVERLAP Nothing-#else- let lazy = NotStrict-# define MAYBE_OVERLAP-#endif let newtypeMVector = newtypeInstD' ''MVector [s, typ] (NormalC mvName [(lazy, ConT ''MVector `AppT` s `AppT` rep)]) let mvCon = ConE mvName- let instanceMVector = InstanceD MAYBE_OVERLAP cxts+ let instanceMVector = InstanceD Nothing cxts (ConT ''M.MVector `AppT` ConT ''MVector `AppT` typ) $ concat [ wrap 'M.basicLength [mv] id , wrap 'M.basicUnsafeSlice [i, n, mv] (AppE mvCon)@@ -149,7 +127,7 @@ (NormalC vName [(lazy, ConT ''Vector `AppT` rep)]) let vCon = ConE vName- let instanceVector = InstanceD MAYBE_OVERLAP cxts+ let instanceVector = InstanceD Nothing cxts (ConT ''G.Vector `AppT` ConT ''Vector `AppT` typ) $ concat [ wrap 'G.basicUnsafeFreeze [mv] (liftE vCon) , wrap 'G.basicUnsafeThaw [v] (liftE mvCon)@@ -159,21 +137,18 @@ , wrap 'G.basicUnsafeCopy [mv, v] id , wrap 'G.elemseq [v, a] id ] - return [ InstanceD MAYBE_OVERLAP cxts (ConT ''Unbox `AppT` typ) []+ return [ InstanceD Nothing cxts (ConT ''Unbox `AppT` typ) [] , newtypeMVector, instanceMVector , newtypeVector, instanceVector ] newtypeInstD' :: Name -> [Type] -> Con -> Dec-newtypeInstD' name args con = +newtypeInstD' name args con = #if MIN_VERSION_template_haskell(2,15,0) NewtypeInstD [] Nothing (foldl AppT (ConT name) args) Nothing con []-#elif MIN_VERSION_template_haskell(2,11,0)- NewtypeInstD [] name args Nothing con [] #else- NewtypeInstD [] name args con []+ NewtypeInstD [] name args Nothing con [] #endif -#undef __GLASGOW_HASKELL__ {-$usage Writing @Unbox@ instances for new data types is tedious and formulaic. More
vector-th-unbox.cabal view
@@ -1,5 +1,5 @@ name: vector-th-unbox-version: 0.2.1.9+version: 0.2.2 synopsis: Deriver for Data.Vector.Unboxed using Template Haskell description: A Template Haskell deriver for unboxed vectors, given a pair of coercion@@ -17,11 +17,10 @@ build-type: Simple cabal-version: >= 1.10 tested-with:- GHC == 7.10.3, GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.4,- GHC == 8.6.5, GHC == 8.8.3, GHC == 8.10.1, GHC == 9.0.1+ GHC == 8.6.5, GHC == 8.8.3, GHC == 8.10.1, GHC == 9.0.1, GHC ==9.2.1 extra-source-files: CHANGELOG.md README.md@@ -36,8 +35,8 @@ Data.Vector.Unboxed.Deriving build-depends:- base >= 4.5 && < 4.16,- template-haskell >= 2.5 && <2.18,+ base >= 4.5 && < 4.17,+ template-haskell >= 2.5 && <2.19, vector >= 0.7.1 && <0.13 test-suite sanity