11 Designing Functional Programs
In this chapter you will learn how to
- design functional real-world applications
- model more complicated requirements as types
- integrate with real data-source APIs using IO
- avoid resource leaks
- cache query results to speed up the execution
What I cannot create, I do not understand.
— Richard Feynman
11.1 Make it work, make it right, make it fast
This quote has a long history, but the presented formulation is attributed to Kent Beck.
It’s time to put all the knowledge you’ve gained to a good use and implement something tangible! We will use all the functional tools and techniques we learned to follow the very old programming advice: first make the solution work, then make it work correctly, and only then think about making it blazingly fast. Here are the requirements, which understandably are a bit more involved than what we were used to: