From afdc22f15886b074b9bd796cd9e6399e887ee969 Mon Sep 17 00:00:00 2001 From: Erik de Castro Lopo Date: Tue, 19 Nov 2024 14:09:21 +1100 Subject: [PATCH] Fix warnings * Replace deprecated `sizeofMutableByteArray` with `getSizeofMutableByteArray`. * Remove use of `List.head` which generates a warning with later GHC versions. Completely un-needed anyway if `QuickCheck.sample'` is replaced with `QuickCheck.generate`. --- src/Data/HashTable/Internal/IntArray.hs | 4 ++-- test/suite/Data/HashTable/Test/Common.hs | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Data/HashTable/Internal/IntArray.hs b/src/Data/HashTable/Internal/IntArray.hs index 5bb57a8..1de6862 100644 --- a/src/Data/HashTable/Internal/IntArray.hs +++ b/src/Data/HashTable/Internal/IntArray.hs @@ -106,8 +106,8 @@ writeArray (IA a) idx val = do ------------------------------------------------------------------------------ -length :: IntArray s -> Int -length (IA a) = A.sizeofMutableByteArray a `div` wordSizeInBytes +length :: IntArray s -> ST s Int +length (IA a) = (`div` wordSizeInBytes) <$> A.getSizeofMutableByteArray a ------------------------------------------------------------------------------ diff --git a/test/suite/Data/HashTable/Test/Common.hs b/test/suite/Data/HashTable/Test/Common.hs index 38d53eb..fd33f73 100644 --- a/test/suite/Data/HashTable/Test/Common.hs +++ b/test/suite/Data/HashTable/Test/Common.hs @@ -15,7 +15,7 @@ module Data.HashTable.Test.Common import Control.Applicative (pure, (<$>)) #endif import Control.Applicative ((<|>)) -import Control.Monad (foldM_, liftM, when) +import Control.Monad (foldM_, when) import qualified Control.Monad as Monad import Data.IORef import Data.List hiding (delete, insert, @@ -32,7 +32,7 @@ import Test.Framework.Providers.QuickCheck2 import Test.HUnit (assertEqual, assertFailure) import Test.QuickCheck (arbitrary, choose, - sample') + generate) import Test.QuickCheck.Monadic (PropertyM, assert, forAllM, monadicIO, pre, run) @@ -242,7 +242,7 @@ testGrowTable prefix dummyArg = prop n = do announceQ "growTable" n ht <- run $ go n - i <- liftM head $ run $ sample' $ choose (0,n-1) + i <- run $ generate $ choose (0,n-1) v <- run $ lookup ht i assertEq ("lookup " ++ show i) (Just i) v @@ -290,7 +290,7 @@ testDelete prefix dummyArg = ht <- run $ go n - i <- liftM head $ run $ sample' $ choose (4,n-1) + i <- run $ generate $ choose (4,n-1) v <- run $ lookup ht i assertEq ("lookup " ++ show i) (Just i) v