This chapter covers
- Writing audio files to the file system
- Modeling a domain specific problem using Haskell’s data types
- Building abstractions and high-level structures around low-level implementations
- Designing a domain specific language (DSL) within Haskell
So far we have been dealing with very earnest topics. Ancient encryption schemes, shortest paths, CSV file mangling are all serious business. In this chapter we want to be a bit more playful and let our creative spirit run free by making music! Don’t worry if you have no instrument ready at hand or general idea how to compose. We will use the power of the Haskell language to not just serve as our own musical synthesizer but also a composition tool to easily create the next musical masterpiece remembered by audiences for centuries!
Modeling real world data inside programs is a normal activity for any programmer. This chapter will specifically teach you how to think about abstracting real world details and modeling a part of a real world system (the system of western music theory) as types and values. This kind of modeling comes up every time you want to write software that incorporates some kind of business logic or concepts not directly related to software specifications or architecture. Haskell allows for highly abstract modeling which fully omits any details that are not relevant to the use case. This is what we are trying to achieve in this chapter.