Skip to content

Commit d691df5

Browse files
committed
Fix (some issues) with the tests
1 parent ef84b0b commit d691df5

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

tests/Strictness.hs

+9-7
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ import Data.Maybe (fromMaybe, isJust)
1414
import Control.Arrow (second)
1515
import Control.Monad (guard)
1616
import Data.Foldable (foldl')
17+
import GHC.TypeNats(KnownNat)
1718
#if !MIN_VERSION_base(4,8,0)
1819
import Data.Functor ((<$))
1920
import Data.Foldable (all)
2021
import Prelude hiding (all)
2122
#endif
2223

23-
import Data.HashMap.Strict (HashMap)
24+
25+
import Data.HashMap.Strict (HashMapT, HashMap)
2426
import qualified Data.HashMap.Strict as HM
2527

2628
-- Key type that generates more hash collisions.
@@ -30,9 +32,9 @@ newtype Key = K { unK :: Int }
3032
instance Hashable Key where
3133
hashWithSalt salt k = hashWithSalt salt (unK k) `mod` 20
3234

33-
instance (Arbitrary k, Arbitrary v, Eq k, Hashable k) =>
34-
Arbitrary (HashMap k v) where
35-
arbitrary = HM.fromList `fmap` arbitrary
35+
instance (Arbitrary k, Arbitrary v, Eq k, Hashable k, KnownNat salt) =>
36+
Arbitrary (HashMapT salt k v) where
37+
arbitrary = HM.fromList' `fmap` arbitrary
3638

3739
instance Show (Int -> Int) where
3840
show _ = "<function>"
@@ -100,7 +102,7 @@ pFromListWithKeyStrict f =
100102
-- could be lazy in the "new" value. fromListWith must, however,
101103
-- be strict in whatever value is actually inserted into the map.
102104
-- Getting all these properties specified efficiently seems tricky.
103-
-- Since it's not hard, we verify that the converted HashMap has
105+
-- Since it's not hard, we verify that the converted HashMapT salt has
104106
-- no unforced values. Rather than trying to go into detail for the
105107
-- rest, this test compares the strictness behavior of fromListWith
106108
-- to that of insertWith. The latter should be easier to specify
@@ -123,7 +125,7 @@ pFromListWithValueResultStrict :: [(Key, Maybe A)]
123125
pFromListWithValueResultStrict lst comb_lazy calc_good_raw
124126
= all (all isJust) recovered .&&. (recovered === recover (fmap recover fake_map))
125127
where
126-
recovered :: Maybe (HashMap Key (Maybe A))
128+
recovered :: Maybe (HashMapT salt Key (Maybe A))
127129
recovered = recover (fmap recover real_map)
128130
-- What we get out of the conversion using insertWith
129131
fake_map = foldl' (\m (k,v) -> HM.insertWith real_comb k v m) HM.empty real_list
@@ -189,7 +191,7 @@ main = defaultMain tests
189191
------------------------------------------------------------------------
190192
-- * Utilities
191193

192-
keyStrict :: (Key -> HashMap Key Int -> a) -> HashMap Key Int -> Bool
194+
keyStrict :: (Key -> HashMapT salt Key Int -> a) -> HashMapT salt Key Int -> Bool
193195
keyStrict f m = isBottom $ f bottom m
194196

195197
const2 :: a -> b -> c -> a

0 commit comments

Comments
 (0)