Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow construction of hashes using their underlying representation #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Data/Digest/Murmur32.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ MurmurHash2 algorithm. See <http://murmurhash.googlepages.com> for
details on MurmurHash2.
-}
module Data.Digest.Murmur32
( Hash32, asWord32,
( Hash32, asWord32, asHash32,
Hashable32(..),
hash32AddWord32, hash32AddInt, hash32, hash32WithSeed
)
Expand All @@ -39,6 +39,10 @@ instance Show Hash32 where
asWord32 :: Hash32 -> Word32
asWord32 (Hash32 w) = w

-- | Coerce a 32 bit word into a hash. This does not hash the input.
asHash32 :: Word32 -> Hash32
asHash32 = Hash32

class Hashable32 a where
hash32Add :: a -> Hash32 -> Hash32

Expand Down
6 changes: 5 additions & 1 deletion Data/Digest/Murmur64.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ MurmurHash2 algorithm. See <http://murmurhash.googlepages.com> for
details on MurmurHash2.
-}
module Data.Digest.Murmur64
( Hash64, asWord64,
( Hash64, asWord64, asHash64,
Hashable64(..),
hash64AddWord64, hash64AddInt, hash64, hash64WithSeed, combine,
)
Expand All @@ -39,6 +39,10 @@ instance Show Hash64 where
asWord64 :: Hash64 -> Word64
asWord64 (Hash64 w) = w

-- | Coerce a 64 bit word into a hash. This does not hash the input.
asHash64 :: Word64 -> Hash64
asHash64 = Hash64

class Hashable64 a where
hash64Add :: a -> Hash64 -> Hash64

Expand Down
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
### Unreleased

- Introduce `asHash64` and `asHash32` which allow construction of `Hash64`
and `Hash32` respectively from their underlying word representation.

### 0.1.0.10

- Replace use of deprecated `bitSize` by `finiteBitSize`
Expand Down