A hash map provides fast access for key-value lookups. In the word ladder solver, it replaces a slower associative-map implementation so large dictionaries can be processed. section 6.3.2
Using a hash map in the Haskell project involves:
- Add unordered-containers and hashable to package.yml. section 6.3.2
- Replace Data.AssocMap with Data.HashMap.Lazy and update related map types. section 6.3.2
- Require Hashable a when map keys use the type variable a. section 6.3.2
Scaling the word ladder solver
The solver initially handles a 200-word dictionary but takes too long with 58,110 words. Substituting HashMap makes the large dictionary workable; profiling then shows candidate computation and file reading as larger costs than map lookup. section 6.3 section 6.3.2
dependencies: - base >= 4.7 && < 5 - unordered-containers - hashable
Dependency configuration for enabling unordered-containers and hashable in the project. section 6.3.2
