# Hash

|  | Contents | Index

Hash

Contents

The `HashTable` type
  Operations on `HashTable`s
The `Hash` class

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

data HashTable key val
new :: (Eq key, Hash key) => Int -> IO (HashTable key val)
insert :: (Eq key, Hash key) => key -> val -> IO ()
lookup :: Hash key => key -> IO (Maybe val)
class Hash a where

hash :: a -> Int

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 `HashTable`s
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.
Methods

hash :: a -> Int
hashes the value of type `a` into an `Int`

Instances

Hash Float
Hash Int
(Hash a, Hash b) => Hash (a, b)

Produced by Haddock version 2.5.0