on master help sign in
Switch over to new hashable interface
commita02428975c5dfe7519ff7e2696469652278c5624 authorBryan O'Sullivan <bos@serpentine.com> dateFri 7 Dec 2012, 09:54 (14 years ago) parent217aa8b
1 file changed+10−6
Data/Aeson/Types/Internal.hs+10−6
Data/Aeson/Types/Internal.hs+10−6
@@ -177,12 +177,16 @@ instance IsString Value where
177177 {-# INLINE fromString #-}
178178
179179instance Hashable Value where
180− hash (Object o) = H.foldl' hashWithSalt 0 o
181− hash (Array a) = V.foldl' hashWithSalt 1 a
182− hash (String s) = 2 `hashWithSalt` s
183− hash (Number n) = 3 `hashWithSalt` case n of I i -> hash i; D d -> hash d
184− hash (Bool b) = 4 `hashWithSalt` b
185− hash Null = 5
180+ hashWithSalt s (Object o) = H.foldl' hashWithSalt
181+ (s `hashWithSalt` (0::Int)) o
182+ hashWithSalt s (Array a) = V.foldl' hashWithSalt
183+ (s `hashWithSalt` (1::Int)) a
184+ hashWithSalt s (String str) = s `hashWithSalt` (2::Int) `hashWithSalt` str
185+ hashWithSalt s (Number n) = 3 `hashWithSalt`
186+ case n of I i -> hashWithSalt s i
187+ D d -> hashWithSalt s d
188+ hashWithSalt s (Bool b) = s `hashWithSalt` (4::Int) `hashWithSalt` b
189+ hashWithSalt s Null = s `hashWithSalt` (5::Int)
186190
187191-- | The empty array.
188192emptyArray :: Value