@@ -14,13 +14,15 @@ import Data.Maybe (fromMaybe, isJust)
1414import Control.Arrow (second )
1515import Control.Monad (guard )
1616import Data.Foldable (foldl' )
17+ import GHC.TypeNats (KnownNat )
1718#if !MIN_VERSION_base(4,8,0)
1819import Data.Functor ((<$) )
1920import Data.Foldable (all )
2021import Prelude hiding (all )
2122#endif
2223
23- import Data.HashMap.Strict (HashMap )
24+
25+ import Data.HashMap.Strict (HashMapT , HashMap )
2426import qualified Data.HashMap.Strict as HM
2527
2628-- Key type that generates more hash collisions.
@@ -30,9 +32,9 @@ newtype Key = K { unK :: Int }
3032instance 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
3739instance 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)]
123125pFromListWithValueResultStrict 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
193195keyStrict f m = isBottom $ f bottom m
194196
195197const2 :: a -> b -> c -> a
0 commit comments