Skip to content

Commit

Permalink
Hash list length too
Browse files Browse the repository at this point in the history
  • Loading branch information
phadej committed Sep 17, 2015
1 parent 3f4f524 commit b042358
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Data/Hashable/Class.hs
Expand Up @@ -430,9 +430,15 @@ instance Hashable (StableName a) where
hash = hashStableName
hashWithSalt = defaultHashWithSalt

-- Auxillary type for Hashable [a] definition
data SPInt = SP !Int !Int

instance Hashable a => Hashable [a] where
{-# SPECIALIZE instance Hashable [Char] #-}
hashWithSalt = foldl' hashWithSalt
hashWithSalt salt arr = finalise (foldl' step (SP salt 0) arr)
where
finalise (SP s l) = hashWithSalt s l
step (SP s l) x = SP (hashWithSalt s x) (l + 1)

instance Hashable B.ByteString where
hashWithSalt salt bs = B.inlinePerformIO $
Expand Down

0 comments on commit b042358

Please sign in to comment.