on master help sign in
Merge
commit2bba1cde57c80c7ffc50da4ad4efe6d6e09eea26 authorBryan O'Sullivan <bos@serpentine.com> dateThu 2 Jan 2014, 14:21 (13 years ago) parentfdf7209f8612d0
1 file changed+11−8
Data/Aeson/Types/Internal.hs+11−8
Data/Aeson/Types/Internal.hs+11−8
@@ -199,15 +199,18 @@ instance IsString Value where
199199 fromString = String . pack
200200 {-# INLINE fromString #-}
201201
202+hashValue :: Int -> Value -> Int
203+hashValue s (Object o) = H.foldl' hashWithSalt
204+ (s `hashWithSalt` (0::Int)) o
205+hashValue s (Array a) = V.foldl' hashWithSalt
206+ (s `hashWithSalt` (1::Int)) a
207+hashValue s (String str) = s `hashWithSalt` (2::Int) `hashWithSalt` str
208+hashValue s (Number n) = s `hashWithSalt` (3::Int) `hashWithSalt` n
209+hashValue s (Bool b) = s `hashWithSalt` (4::Int) `hashWithSalt` b
210+hashValue s Null = s `hashWithSalt` (5::Int)
211+
202212instance Hashable Value where
203− hashWithSalt s (Object o) = H.foldl' hashWithSalt
204− (s `hashWithSalt` (0::Int)) o
205− hashWithSalt s (Array a) = V.foldl' hashWithSalt
206− (s `hashWithSalt` (1::Int)) a
207− hashWithSalt s (String str) = s `hashWithSalt` (2::Int) `hashWithSalt` str
208− hashWithSalt s (Number n) = s `hashWithSalt` (3::Int) `hashWithSalt` n
209− hashWithSalt s (Bool b) = s `hashWithSalt` (4::Int) `hashWithSalt` b
210− hashWithSalt s Null = s `hashWithSalt` (5::Int)
213+ hashWithSalt = hashValue
211214
212215-- | The empty array.
213216emptyArray :: Value