From 22d75d034676e86f311805a3ef402d21ba99a38b Mon Sep 17 00:00:00 2001 From: Alexey Kuleshevich Date: Sun, 1 Dec 2024 17:51:49 -0700 Subject: [PATCH] Revert primitiver stuff --- .github/workflows/ci.yaml | 2 +- random.cabal | 1 - stack-old.yaml | 1 + stack.lts-18.yaml | 1 - test/Spec.hs | 12 ++++++------ 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ef5650bf..97e726fa 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -293,7 +293,7 @@ jobs: githubToken: ${{ github.token }} install: | apt-get update -y - apt-get install -y git ghc libghc-primitive-dev libghc-tasty-smallcheck-dev libghc-tasty-hunit-dev libghc-splitmix-dev curl + apt-get install -y git ghc libghc-tasty-smallcheck-dev libghc-tasty-hunit-dev libghc-splitmix-dev curl run: | git clone https://github.com/Bodigrim/data-array-byte cp -r data-array-byte/Data . diff --git a/random.cabal b/random.cabal index 5ca8a375..1af91647 100644 --- a/random.cabal +++ b/random.cabal @@ -141,7 +141,6 @@ test-suite spec build-depends: base, bytestring, - primitive >=0.8, random, smallcheck >=1.2 && <1.3, stm, diff --git a/stack-old.yaml b/stack-old.yaml index 3ae83ed3..986cdc0b 100644 --- a/stack-old.yaml +++ b/stack-old.yaml @@ -8,6 +8,7 @@ extra-deps: - tasty-1.3.1@sha256:01e35c97f7ee5ccbc28f21debea02a38cd010d53b4c3087f5677c5d06617a507,2520 - ansi-wl-pprint-0.6.8.2@sha256:a890b713942c1aa0109fb632e9fee581ceb5b0763fd936ae8cae22e5f91a0877,2178 - ansi-terminal-0.9.1@sha256:48f53532d0f365ffa568c8cf0adc84c66f800a7d80d3329e4f04fa75392f4af1,3225 +- wcwidth-0.0.2@sha256:77531eb6683c505c22ab3fa11bbc43d3ce1e7dac21401d4d5a19677d348bb5f3,1998 - tasty-bench-0.2.3@sha256:daa2221a1b1c65990633a51236f1cb4a52cba8ef0f0731f653e712a8bab07616,1319 - inspection-testing-0.4.5.0@sha256:938e7ce2ef42033071a5e60198c6e19ab61c411f5879b85821247a504f131768,8058 - tasty-inspection-testing-0.1@sha256:9c5e76345168fd3a59b43d305eebf8df3c792ce324c66bbdee45b54aa7d2c0ad,1214 diff --git a/stack.lts-18.yaml b/stack.lts-18.yaml index bc8f7773..320440f4 100644 --- a/stack.lts-18.yaml +++ b/stack.lts-18.yaml @@ -3,4 +3,3 @@ packages: - . extra-deps: - data-array-byte-0.1.0.1@sha256:ad89e28b2b046175698fbf542af2ce43e5d2af50aae9f48d12566b1bb3de1d3c,1989 -- primitive-0.9.0.0@sha256:de20bf4eff1f972088854c8efda6eaca2d3147aff62232c3707f059152638759,3203 diff --git a/test/Spec.hs b/test/Spec.hs index 1477d409..2ab67cf2 100644 --- a/test/Spec.hs +++ b/test/Spec.hs @@ -17,7 +17,6 @@ import qualified Data.ByteString.Short as SBS import Data.Int import Data.List (sortOn) import Data.List.NonEmpty (NonEmpty(..)) -import Data.Primitive.ByteArray (newByteArray, unsafeFreezeByteArray, writeByteArray) import Data.Typeable import Data.Void import Data.Word @@ -26,6 +25,7 @@ import GHC.Generics import GHC.Exts (fromList) import Numeric.Natural (Natural) import System.Random.Stateful +import System.Random.Internal (newMutableByteArray, freezeMutableByteArray, writeWord8) import Test.SmallCheck.Series as SC import Test.Tasty import Test.Tasty.HUnit @@ -151,18 +151,18 @@ fillMutableByteArraySpec = [ SC.testProperty "Same as uniformByteArray" $ forAll $ \isPinned -> seededWithLen $ \n g -> let baFilled = runST $ do - mba <- newByteArray n + mba <- newMutableByteArray n g' <- uniformFillMutableByteArray mba 0 n g - ba <- unsafeFreezeByteArray mba + ba <- freezeMutableByteArray mba pure (ba, g') in baFilled == uniformByteArray isPinned n g , SC.testProperty "Safe uniformFillMutableByteArray" $ forAll $ \isPinned offset count -> seededWithLen $ \sz g -> let (baFilled, gf) = runST $ do - mba <- newByteArray sz - forM_ [0 .. sz - 1] (\i -> writeByteArray mba i (0 :: Word8)) + mba <- newMutableByteArray sz + forM_ [0 .. sz - 1] (\i -> writeWord8 mba i 0) g' <- uniformFillMutableByteArray mba offset count g - ba <- unsafeFreezeByteArray mba + ba <- freezeMutableByteArray mba pure (ba, g') (baGen, gu) = uniformByteArray isPinned count' g offset' = min sz (max 0 offset)