@@ -311,7 +311,7 @@ instance Bifoldable HashMap where
311311--
312312-- >>> fromList [(1,'a'),(2,'b')] <> fromList [(2,'c'),(3,'d')]
313313-- fromList [(1,'a'),(2,'b'),(3,'d')]
314- instance ( Eq k , Hashable k ) => Semigroup (HashMap k v ) where
314+ instance Hashable k => Semigroup (HashMap k v ) where
315315 (<>) = union
316316 {-# INLINE (<>) #-}
317317 stimes = stimesIdempotentMonoid
@@ -327,13 +327,13 @@ instance (Eq k, Hashable k) => Semigroup (HashMap k v) where
327327--
328328-- >>> mappend (fromList [(1,'a'),(2,'b')]) (fromList [(2,'c'),(3,'d')])
329329-- fromList [(1,'a'),(2,'b'),(3,'d')]
330- instance ( Eq k , Hashable k ) => Monoid (HashMap k v ) where
330+ instance Hashable k => Monoid (HashMap k v ) where
331331 mempty = empty
332332 {-# INLINE mempty #-}
333333 mappend = (<>)
334334 {-# INLINE mappend #-}
335335
336- instance (Data k , Data v , Eq k , Hashable k ) => Data (HashMap k v ) where
336+ instance (Data k , Data v , Hashable k ) => Data (HashMap k v ) where
337337 gfoldl f z m = z fromList `f` toList m
338338 toConstr _ = fromListConstr
339339 gunfold k z c = case Data. constrIndex c of
@@ -376,14 +376,14 @@ instance Show2 HashMap where
376376instance Show k => Show1 (HashMap k ) where
377377 liftShowsPrec = liftShowsPrec2 showsPrec showList
378378
379- instance (Eq k , Hashable k , Read k ) => Read1 (HashMap k ) where
379+ instance (Hashable k , Read k ) => Read1 (HashMap k ) where
380380 liftReadsPrec rp rl = FC. readsData $
381381 FC. readsUnaryWith (liftReadsPrec rp' rl') " fromList" fromList
382382 where
383383 rp' = liftReadsPrec rp rl
384384 rl' = liftReadList rp rl
385385
386- instance (Eq k , Hashable k , Read k , Read e ) => Read (HashMap k e ) where
386+ instance (Hashable k , Read k , Read e ) => Read (HashMap k e ) where
387387 readPrec = parens $ prec 10 $ do
388388 Ident " fromList" <- lexP
389389 fromList <$> readPrec
@@ -624,15 +624,15 @@ size t = go t 0
624624
625625-- | \(O(\log n)\) Return 'True' if the specified key is present in the
626626-- map, 'False' otherwise.
627- member :: ( Eq k , Hashable k ) => k -> HashMap k a -> Bool
627+ member :: Hashable k => k -> HashMap k a -> Bool
628628member k m = case lookup k m of
629629 Nothing -> False
630630 Just _ -> True
631631{-# INLINABLE member #-}
632632
633633-- | \(O(\log n)\) Return the value to which the specified key is mapped,
634634-- or 'Nothing' if this map contains no mapping for the key.
635- lookup :: ( Eq k , Hashable k ) => k -> HashMap k v -> Maybe v
635+ lookup :: Hashable k => k -> HashMap k v -> Maybe v
636636-- GHC does not yet perform a worker-wrapper transformation on
637637-- unboxed sums automatically. That seems likely to happen at some
638638-- point (possibly as early as GHC 8.6) but for now we do it manually.
@@ -641,7 +641,7 @@ lookup k m = case lookup# k m of
641641 (# | a # ) -> Just a
642642{-# INLINE lookup #-}
643643
644- lookup # :: ( Eq k , Hashable k ) => k -> HashMap k v -> (# (# # ) | v # )
644+ lookup # :: Hashable k => k -> HashMap k v -> (# (# # ) | v # )
645645lookup # k m = lookupCont (\ _ -> (# (# # ) | # )) (\ v _i -> (# | v # )) (hash k) k 0 m
646646{-# INLINABLE lookup# #-}
647647
@@ -746,7 +746,7 @@ lookupCont absent present !h0 !k0 !s0 m0 = go h0 k0 s0 m0
746746-- This is a flipped version of 'lookup'.
747747--
748748-- @since 0.2.11
749- (!?) :: ( Eq k , Hashable k ) => HashMap k v -> k -> Maybe v
749+ (!?) :: Hashable k => HashMap k v -> k -> Maybe v
750750(!?) m k = lookup k m
751751{-# INLINE (!?) #-}
752752
@@ -755,7 +755,7 @@ lookupCont absent present !h0 !k0 !s0 m0 = go h0 k0 s0 m0
755755-- or the default value if this map contains no mapping for the key.
756756--
757757-- @since 0.2.11
758- findWithDefault :: ( Eq k , Hashable k )
758+ findWithDefault :: Hashable k
759759 => v -- ^ Default value to return.
760760 -> k -> HashMap k v -> v
761761findWithDefault def k t = case lookup k t of
@@ -769,15 +769,15 @@ findWithDefault def k t = case lookup k t of
769769--
770770-- DEPRECATED: lookupDefault is deprecated as of version 0.2.11, replaced
771771-- by 'findWithDefault'.
772- lookupDefault :: ( Eq k , Hashable k )
772+ lookupDefault :: Hashable k
773773 => v -- ^ Default value to return.
774774 -> k -> HashMap k v -> v
775775lookupDefault = findWithDefault
776776{-# INLINE lookupDefault #-}
777777
778778-- | \(O(\log n)\) Return the value to which the specified key is mapped.
779779-- Calls 'error' if this map contains no mapping for the key.
780- (!) :: (Eq k , Hashable k , HasCallStack ) => HashMap k v -> k -> v
780+ (!) :: (Hashable k , HasCallStack ) => HashMap k v -> k -> v
781781(!) m k = case lookup k m of
782782 Just v -> v
783783 Nothing -> error " Data.HashMap.Internal.(!): key not found"
@@ -841,7 +841,7 @@ bitmapIndexedOrFull b !ary
841841-- | \(O(\log n)\) Associate the specified value with the specified
842842-- key in this map. If this map previously contained a mapping for
843843-- the key, the old value is replaced.
844- insert :: ( Eq k , Hashable k ) => k -> v -> HashMap k v -> HashMap k v
844+ insert :: Hashable k => k -> v -> HashMap k v -> HashMap k v
845845insert k v m = insert' (hash k) k v m
846846{-# INLINABLE insert #-}
847847
@@ -959,7 +959,7 @@ setAtPosition i k x ary = A.update ary i (L k x)
959959
960960
961961-- | In-place update version of insert
962- unsafeInsert :: forall k v . ( Eq k , Hashable k ) => k -> v -> HashMap k v -> HashMap k v
962+ unsafeInsert :: forall k v . Hashable k => k -> v -> HashMap k v -> HashMap k v
963963unsafeInsert k0 v0 m0 = runST (go h0 k0 v0 0 m0)
964964 where
965965 h0 = hash k0
@@ -1036,7 +1036,7 @@ two = go
10361036--
10371037-- > insertWith f k v map
10381038-- > where f new old = new + old
1039- insertWith :: ( Eq k , Hashable k ) => (v -> v -> v ) -> k -> v -> HashMap k v
1039+ insertWith :: Hashable k => (v -> v -> v ) -> k -> v -> HashMap k v
10401040 -> HashMap k v
10411041-- We're not going to worry about allocating a function closure
10421042-- to pass to insertModifying. See comments at 'adjust'.
@@ -1048,7 +1048,7 @@ insertWith f k new m = insertModifying new (\old -> (# f new old #)) k m
10481048-- to apply to calculate a new value when the key is present. Thanks
10491049-- to the unboxed unary tuple, we avoid introducing any unnecessary
10501050-- thunks in the tree.
1051- insertModifying :: ( Eq k , Hashable k ) => v -> (v -> (# v # )) -> k -> HashMap k v
1051+ insertModifying :: Hashable k => v -> (v -> (# v # )) -> k -> HashMap k v
10521052 -> HashMap k v
10531053insertModifying x f k0 m0 = go h0 k0 0 m0
10541054 where
@@ -1112,13 +1112,13 @@ insertModifyingArr x f k0 ary0 = go k0 ary0 0 (A.length ary0)
11121112{-# INLINE insertModifyingArr #-}
11131113
11141114-- | In-place update version of insertWith
1115- unsafeInsertWith :: forall k v . ( Eq k , Hashable k )
1115+ unsafeInsertWith :: forall k v . Hashable k
11161116 => (v -> v -> v ) -> k -> v -> HashMap k v
11171117 -> HashMap k v
11181118unsafeInsertWith f k0 v0 m0 = unsafeInsertWithKey (\ _ a b -> (# f a b # )) k0 v0 m0
11191119{-# INLINABLE unsafeInsertWith #-}
11201120
1121- unsafeInsertWithKey :: forall k v . ( Eq k , Hashable k )
1121+ unsafeInsertWithKey :: forall k v . Hashable k
11221122 => (k -> v -> v -> (# v # )) -> k -> v -> HashMap k v
11231123 -> HashMap k v
11241124unsafeInsertWithKey f k0 v0 m0 = runST (go h0 k0 v0 0 m0)
@@ -1156,7 +1156,7 @@ unsafeInsertWithKey f k0 v0 m0 = runST (go h0 k0 v0 0 m0)
11561156
11571157-- | \(O(\log n)\) Remove the mapping for the specified key from this map
11581158-- if present.
1159- delete :: ( Eq k , Hashable k ) => k -> HashMap k v -> HashMap k v
1159+ delete :: Hashable k => k -> HashMap k v -> HashMap k v
11601160delete k m = delete' (hash k) k m
11611161{-# INLINABLE delete #-}
11621162
@@ -1251,7 +1251,7 @@ deleteKeyExists !collPos0 !h0 !k0 m0 = go collPos0 h0 k0 m0
12511251
12521252-- | \(O(\log n)\) Adjust the value tied to a given key in this map only
12531253-- if it is present. Otherwise, leave the map alone.
1254- adjust :: ( Eq k , Hashable k ) => (v -> v ) -> k -> HashMap k v -> HashMap k v
1254+ adjust :: Hashable k => (v -> v ) -> k -> HashMap k v -> HashMap k v
12551255-- This operation really likes to leak memory, so using this
12561256-- indirect implementation shouldn't hurt much. Furthermore, it allows
12571257-- GHC to avoid a leak when the function is lazy. In particular,
@@ -1263,7 +1263,7 @@ adjust f k m = adjust# (\v -> (# f v #)) k m
12631263{-# INLINE adjust #-}
12641264
12651265-- | Much like 'adjust', but not inherently leaky.
1266- adjust# :: ( Eq k , Hashable k ) => (v -> (# v # )) -> k -> HashMap k v -> HashMap k v
1266+ adjust# :: Hashable k => (v -> (# v # )) -> k -> HashMap k v -> HashMap k v
12671267adjust# f k0 m0 = go h0 k0 0 m0
12681268 where
12691269 h0 = hash k0
@@ -1305,7 +1305,7 @@ adjust# f k0 m0 = go h0 k0 0 m0
13051305-- | \(O(\log n)\) The expression @('update' f k map)@ updates the value @x@ at @k@
13061306-- (if it is in the map). If @(f x)@ is 'Nothing', the element is deleted.
13071307-- If it is @('Just' y)@, the key @k@ is bound to the new value @y@.
1308- update :: ( Eq k , Hashable k ) => (a -> Maybe a ) -> k -> HashMap k a -> HashMap k a
1308+ update :: Hashable k => (a -> Maybe a ) -> k -> HashMap k a -> HashMap k a
13091309update f = alter (>>= f)
13101310{-# INLINABLE update #-}
13111311
@@ -1318,7 +1318,7 @@ update f = alter (>>= f)
13181318-- @
13191319-- 'lookup' k ('alter' f k m) = f ('lookup' k m)
13201320-- @
1321- alter :: ( Eq k , Hashable k ) => (Maybe v -> Maybe v ) -> k -> HashMap k v -> HashMap k v
1321+ alter :: Hashable k => (Maybe v -> Maybe v ) -> k -> HashMap k v -> HashMap k v
13221322alter f k m =
13231323 let ! h = hash k
13241324 ! lookupRes = lookupRecordCollision h k m
@@ -1343,7 +1343,7 @@ alter f k m =
13431343-- <https://hackage.haskell.org/package/lens/docs/Control-Lens-At.html#v:at Control.Lens.At>.
13441344--
13451345-- @since 0.2.10
1346- alterF :: (Functor f , Eq k , Hashable k )
1346+ alterF :: (Functor f , Hashable k )
13471347 => (Maybe v -> f (Maybe v )) -> k -> HashMap k v -> f (HashMap k v )
13481348-- We only calculate the hash once, but unless this is rewritten
13491349-- by rules we may test for key equality multiple times.
@@ -1433,7 +1433,7 @@ bogus# _ = error "Data.HashMap.alterF internal error: hit bogus#"
14331433--
14341434-- Failure to abide by these laws will make demons come out of your nose.
14351435alterFWeird
1436- :: (Functor f , Eq k , Hashable k )
1436+ :: (Functor f , Hashable k )
14371437 => f (Maybe v )
14381438 -> f (Maybe v )
14391439 -> (Maybe v -> f (Maybe v )) -> k -> HashMap k v -> f (HashMap k v )
@@ -1443,7 +1443,7 @@ alterFWeird _ _ f = alterFEager f
14431443-- | This is the default version of alterF that we use in most non-trivial
14441444-- cases. It's called "eager" because it looks up the given key in the map
14451445-- eagerly, whether or not the given function requires that information.
1446- alterFEager :: (Functor f , Eq k , Hashable k )
1446+ alterFEager :: (Functor f , Hashable k )
14471447 => (Maybe v -> f (Maybe v )) -> k -> HashMap k v -> f (HashMap k v )
14481448alterFEager f ! k m = (<$> f mv) $ \ case
14491449
@@ -1492,7 +1492,7 @@ alterFEager f !k m = (<$> f mv) $ \case
14921492-- False
14931493--
14941494-- @since 0.2.12
1495- isSubmapOf :: (Eq k , Hashable k , Eq v ) => HashMap k v -> HashMap k v -> Bool
1495+ isSubmapOf :: (Hashable k , Eq v ) => HashMap k v -> HashMap k v -> Bool
14961496isSubmapOf = Exts. inline isSubmapOfBy (==)
14971497{-# INLINABLE isSubmapOf #-}
14981498
@@ -1512,7 +1512,7 @@ isSubmapOf = Exts.inline isSubmapOfBy (==)
15121512-- False
15131513--
15141514-- @since 0.2.12
1515- isSubmapOfBy :: ( Eq k , Hashable k ) => (v1 -> v2 -> Bool ) -> HashMap k v1 -> HashMap k v2 -> Bool
1515+ isSubmapOfBy :: Hashable k => (v1 -> v2 -> Bool ) -> HashMap k v1 -> HashMap k v2 -> Bool
15161516-- For maps without collisions the complexity is O(n*log m), where n is the size
15171517-- of m1 and m the size of m2: the inclusion operation visits every leaf in m1 at least once.
15181518-- For each leaf in m1, it looks up the key in m2.
@@ -1766,7 +1766,7 @@ unions = List.foldl' union empty
17661766-- @
17671767--
17681768-- @since 0.2.13.0
1769- compose :: ( Eq b , Hashable b ) => HashMap b c -> HashMap a b -> HashMap a c
1769+ compose :: Hashable b => HashMap b c -> HashMap a b -> HashMap a c
17701770compose bc ! ab
17711771 | null bc = empty
17721772 | otherwise = mapMaybe (bc !? ) ab
@@ -1829,7 +1829,7 @@ traverseWithKey f = go
18291829-- fromList [(3,"c")]
18301830--
18311831-- @since 0.2.14.0
1832- mapKeys :: ( Eq k2 , Hashable k2 ) => (k1 -> k2 ) -> HashMap k1 v -> HashMap k2 v
1832+ mapKeys :: Hashable k2 => (k1 -> k2 ) -> HashMap k1 v -> HashMap k2 v
18331833mapKeys f = fromList . foldrWithKey (\ k x xs -> (f k, x) : xs) []
18341834
18351835------------------------------------------------------------------------
@@ -2559,7 +2559,7 @@ toList t = Exts.build (\ c z -> foldrWithKey (curry c) z t)
25592559
25602560-- | \(O(n \log n)\) Construct a map with the supplied mappings. If the list
25612561-- contains duplicate mappings, the later mappings take precedence.
2562- fromList :: ( Eq k , Hashable k ) => [(k , v )] -> HashMap k v
2562+ fromList :: Hashable k => [(k , v )] -> HashMap k v
25632563fromList = List. foldl' (\ m (k, v) -> unsafeInsert k v m) empty
25642564{-# INLINABLE fromList #-}
25652565
@@ -2593,7 +2593,7 @@ fromList = List.foldl' (\ m (k, v) -> unsafeInsert k v m) empty
25932593--
25942594-- > fromListWith f [(k, a), (k, b), (k, c), (k, d)]
25952595-- > = fromList [(k, f d (f c (f b a)))]
2596- fromListWith :: ( Eq k , Hashable k ) => (v -> v -> v ) -> [(k , v )] -> HashMap k v
2596+ fromListWith :: Hashable k => (v -> v -> v ) -> [(k , v )] -> HashMap k v
25972597fromListWith f = List. foldl' (\ m (k, v) -> unsafeInsertWith f k v m) empty
25982598{-# INLINE fromListWith #-}
25992599
@@ -2623,7 +2623,7 @@ fromListWith f = List.foldl' (\ m (k, v) -> unsafeInsertWith f k v m) empty
26232623-- > = fromList [(k, f k d (f k c (f k b a)))]
26242624--
26252625-- @since 0.2.11
2626- fromListWithKey :: ( Eq k , Hashable k ) => (k -> v -> v -> v ) -> [(k , v )] -> HashMap k v
2626+ fromListWithKey :: Hashable k => (k -> v -> v -> v ) -> [(k , v )] -> HashMap k v
26272627fromListWithKey f = List. foldl' (\ m (k, v) -> unsafeInsertWithKey (\ k' a b -> (# f k' a b # )) k v m) empty
26282628{-# INLINE fromListWithKey #-}
26292629
@@ -2893,7 +2893,7 @@ otherOfOneOrZero i = 1 - i
28932893#if defined(__GLASGOW_HASKELL__)
28942894------------------------------------------------------------------------
28952895-- IsList instance
2896- instance ( Eq k , Hashable k ) => Exts. IsList (HashMap k v ) where
2896+ instance Hashable k => Exts. IsList (HashMap k v ) where
28972897 type Item (HashMap k v ) = (k , v )
28982898 fromList = fromList
28992899 toList = toList
0 commit comments