One of the greatest tools in the functional programmer’s tool belt is the notion of composure. It’s a pattern that allows you to take two things and combine them, like LEGO pieces or the segmented tracks of a train set, and join them together in a myriad of ways with different structures or pathways each time.
Combined with functors and monads, this very simple concept can be used not only to transform data in complex ways, but also ensure its validity and handle errors and invalid input effortlessly without ever causing your program to crash.
This talk will start with the basic building blocks of function composition— pure, endomorphic functions— and then discuss how curry and compose assist in combining these blocks. It will illustrate how functors can be used when the presence or type of input is uncertain, how monads can provide multiple validity checks without breaking a sweat, and how map and chain let us continue to compose away effortlessly under these circumstances.
Understanding and utilizing composure to solve real world problems in programming will produce code that is clean, agile, and reliable. These benefits are accessible to both the seasoned developer and the beginner.