From c8abe94a05841d5de0adea7b9afd45fc37981d4e Mon Sep 17 00:00:00 2001 From: mu <59917266+4eUeP@users.noreply.github.com> Date: Fri, 28 Jun 2024 16:10:47 +0800 Subject: [PATCH] bump primitive upper bound to 0.9 --- .github/workflows/publish.yml | 6 +++--- .github/workflows/ubuntuCI.yml | 2 +- Z-Data.cabal | 4 ++-- Z/Data/Array/Base.hs | 21 ++++++++++++++++----- Z/Foreign.hs | 8 +++++++- Z/Foreign/CPtr.hs | 22 +++++++++++++--------- 6 files changed, 42 insertions(+), 21 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 3f7793c..962f05f 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -24,10 +24,10 @@ jobs: ${{ runner.os }}- - name: Setup Haskell - uses: haskell/actions/setup@v1 + uses: haskell-actions/setup@v2 with: - ghc-version: 9.2 - cabal-version: 3.6 + ghc-version: 9.6 + cabal-version: 3.8 - name: Publish package run: | diff --git a/.github/workflows/ubuntuCI.yml b/.github/workflows/ubuntuCI.yml index a6574fb..27b61a2 100644 --- a/.github/workflows/ubuntuCI.yml +++ b/.github/workflows/ubuntuCI.yml @@ -24,7 +24,7 @@ jobs: submodules: 'recursive' - name: Setup Haskell - uses: haskell/actions/setup@v2 + uses: haskell-actions/setup@v2 id: setup-haskell-cabal # <--- give it a name for later cache usage with: ghc-version: ${{ matrix.ghc }} diff --git a/Z-Data.cabal b/Z-Data.cabal index f01d984..6cbcd21 100644 --- a/Z-Data.cabal +++ b/Z-Data.cabal @@ -1,6 +1,6 @@ cabal-version: 2.4 name: Z-Data -version: 2.0.0.2 +version: 2.0.1.0 synopsis: Array, vector and text description: This package provides array, slice and text operations license: BSD-3-Clause @@ -185,7 +185,7 @@ library , containers ^>=0.6 , deepseq ^>=1.4 , hashable >=1.3 && < 1.5 - , primitive >=0.7.3 && <0.8 + , primitive >=0.7.3 && <1.0 , QuickCheck >=2.10 , random >=1.2.0 && <1.3 , scientific >=0.3.7 && <0.4 diff --git a/Z/Data/Array/Base.hs b/Z/Data/Array/Base.hs index 15e08ac..d214b45 100644 --- a/Z/Data/Array/Base.hs +++ b/Z/Data/Array/Base.hs @@ -62,20 +62,27 @@ module Z.Data.Array.Base ( , sizeOf ) where -import Control.Exception (ArrayException (..), throw) +import Control.Exception (ArrayException (..), throw) import Control.Monad import Control.Monad.Primitive import Control.Monad.ST -import Data.Bits (unsafeShiftL) -import Data.Kind (Type) +import Data.Bits (unsafeShiftL) +import Data.Kind (Type) import Data.Primitive.Array import Data.Primitive.ByteArray +#if !MIN_VERSION_primitive(0, 9, 0) import Data.Primitive.PrimArray -import Data.Primitive.Ptr (copyPtrToMutablePrimArray) +#else +import Data.Primitive.PrimArray hiding + (withMutablePrimArrayContents, + withPrimArrayContents) +#endif +import Data.Primitive.Ptr (copyPtrToMutablePrimArray) import Data.Primitive.SmallArray import Data.Primitive.Types import GHC.Exts -import System.Random.Stateful ( UniformRange(uniformRM), StatefulGen ) +import System.Random.Stateful (StatefulGen, + UniformRange (uniformRM)) import Z.Data.Array.Cast import Z.Data.Array.UnliftedArray @@ -589,6 +596,8 @@ instance PrimUnlifted a => Arr UnliftedArray a where -------------------------------------------------------------------------------- +-- FIXME: directly use Data.Primitive.PrimArray.withPrimArrayContents +-- when primitive>=0.9.0 ? -- | Obtain the pointer to the content of an array, and the pointer should only be used during the IO action. -- -- This operation is only safe on /pinned/ primitive arrays (Arrays allocated by 'newPinnedPrimArray' or @@ -604,6 +613,8 @@ withPrimArrayContents (PrimArray ba#) f = do primitive_ (touch# ba#) return b +-- FIXME: directly use Data.Primitive.PrimArray.withMutablePrimArrayContents +-- when primitive>=0.9.0 ? -- | Obtain the pointer to the content of an mutable array, and the pointer should only be used during the IO action. -- -- This operation is only safe on /pinned/ primitive arrays (Arrays allocated by 'newPinnedPrimArray' or diff --git a/Z/Foreign.hs b/Z/Foreign.hs index 8a6f064..2cfd788 100644 --- a/Z/Foreign.hs +++ b/Z/Foreign.hs @@ -109,9 +109,15 @@ import Data.ByteString.Short.Internal (ShortByteString (..), fromShort, toShort) import qualified Data.ByteString.Unsafe as B import qualified Data.List as List -import Data.Primitive import Data.Primitive.ByteArray +import Data.Primitive.Types +#if !MIN_VERSION_primitive(0, 9, 0) import Data.Primitive.PrimArray +#else +import Data.Primitive.PrimArray hiding + (withMutablePrimArrayContents, + withPrimArrayContents) +#endif import Data.Primitive.Ptr import Data.Word import Foreign.C.Types diff --git a/Z/Foreign/CPtr.hs b/Z/Foreign/CPtr.hs index f3c2947..b896c34 100644 --- a/Z/Foreign/CPtr.hs +++ b/Z/Foreign/CPtr.hs @@ -21,15 +21,19 @@ module Z.Foreign.CPtr ( , FunPtr ) where -import Control.Monad -import Control.Monad.Primitive -import Data.Primitive.PrimArray -import qualified Z.Data.Text as T -import GHC.Ptr -import GHC.Exts -import GHC.IO -import Z.Data.Array hiding (newPinnedPrimArray) -import Z.Foreign +import Control.Monad +import Control.Monad.Primitive +#if !MIN_VERSION_primitive(0, 9, 0) +import Data.Primitive.PrimArray +#else +import Data.Primitive.PrimArray hiding (withMutablePrimArrayContents) +#endif +import GHC.Exts +import GHC.IO +import GHC.Ptr +import Z.Data.Array hiding (newPinnedPrimArray) +import qualified Z.Data.Text as T +import Z.Foreign -- | Lightweight foreign pointers. newtype CPtr a = CPtr (PrimArray (Ptr a))