Safe HaskellSafe

Hash

Contents

Description

Implementation of fixed-size hash tables, with a type class for constructing hash values for structured types.

Synopsis

The HashTable type

data HashTable key val #

A hash table with keys of type key and values of type val. The type key should be an instance of Eq.

Operations on HashTables

new :: (Eq key, Hash key) => Int -> IO (HashTable key val) #

Builds a new hash table with a given size

insert :: (Eq key, Hash key) => key -> val -> IO () #

Inserts a new element into the hash table

lookup :: Hash key => key -> IO (Maybe val) #

Looks up a key in the hash table, returns Just val if the key was found, or Nothing otherwise.

The Hash class

class Hash a where #

A class of types which can be hashed.

Minimal complete definition

hash

Methods

hash :: a -> Int #

hashes the value of type a into an Int

Instances

Hash Float #

Methods

hash :: Float -> Int #

Hash Int #

Methods

hash :: Int -> Int #

(Hash a, Hash b) => Hash (a, b) #

Methods

hash :: (a, b) -> Int #