Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7492127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T16:22:17+00:00 2026-05-29T16:22:17+00:00

How can I hash a string in haskell to get a more-or-less unique hash

  • 0

How can I hash a string in haskell to get a more-or-less unique hash value. For example:

hash:: String -> Integer

>hash "foo"
1234123412
>hash "bar"
5938454

Or something along those lines? I’m not familiar with hashing in haskell so any help would be appreciated! Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T16:22:19+00:00Added an answer on May 29, 2026 at 4:22 pm

    You can use the hashable package from Hackage. It provides hash functions for a number of standard types, including strings:

    Prelude Data.Hashable> hash "foo"
    653367
    Prelude Data.Hashable> hash "bar"
    649056
    

    If you want to implement your own, hash functions are usually easy to express as a fold. For example, here’s a variant of the DJB2 hash:

    hash :: String -> Int
    hash = foldl' (\h c -> 33*h `xor` fromEnum c) 5381
    

    Note that these hash functions are meant to be simple and fast. If you’re looking for more complex hash functions, you can find a selection in the cryptohash package.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I create a GUID (as a string) and get the hash of it. Can
How can I get the value of the URL hash (eg PARAMETERS in url
If we can't decode the MD5 hash string, then what is the purpose of
How can I generate hash value for a byte array, in J2ME? It doesn't
In php there is md5() to get a MD5 hash of string passed to
Possible Duplicate: Generate a Hash from string in Javascript/jQuery Can anyone suggest a simple
In http://www.anyexample.com/programming/java/java_simple_class_to_compute_md5_hash.xml an example is given how to calculate an MD5 hash of String.
Is there any chance that a SHA-1 hash can be purely numeric, or does
What's the best way to implement a Hash that can be modified across multiple
How can I store a hash table with separate chaining in a file on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.