5 Higher-kinded composition
This chapter covers
- Transforming arrays and objects safely with
map
andflatMap
- Composable design patterns with algebraic data types
- Writing a
Validation
data type to remove complex branching logic - Chaining ADTs using the new bind operator (
::
)
The purpose of abstraction is not to be vague, but to create a new semantic level in which one can be absolutely precise.
—Edgar Dijkstra
In chapter 4, you learned how function composition leads to fluent, compact, and declarative code when you use compose
to chain your function’s inputs and outputs as data passes through them. Composition has a lot of benefits because it uses JavaScript’s strongest feature, as I’ve said many times: higher-order functions. With functions, ...
Get The Joy of JavaScript now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.