In this chapter, you worked through several iterative improvements of an edit distance calculator for spellchecking, and in the process learned some common techniques for improving the performance of your applications. Optimization in Haskell is a large topic, and there are many techniques that we haven’t touched on in this chapter. Importantly though, the examples in this chapter have introduced you to some of the major concerns that you should keep in mind when looking at improving the performance of your Haskell applications:

  1. Use the profiler early and often to identify expensive parts of your program.

  2. Address algorithmic inefficiencies before data structures and micro-optimizations.

  3. Look at opportunities to avoid doing too many memory allocations, and try to avoid too much indirection.

  4. Use tools like ST to write imperative algorithms when they offer well-known efficient solutions to common problems.