Chapter 4. Patterns in functional programming

This chapter covers

  • The core functions Map, Bind, Where, and ForEach
  • Introducing functors and monads
  • Working at different levels of abstraction

A pattern is a solution that can be applied to solve a variety of problems. The patterns we’ll discuss in this chapter are simply functions; functions that are so ubiquitous when coding functionally that they can be seen as the core functions of FP.

You’re probably familiar with some of these functions, like Where and Select, having used them with IEnumerable. But you’ll see that the same operations can be applied to other structures, hence establishing a pattern. I’ll illustrate this with Option in this chapter; other structures will follow in coming ...

Get Functional Programming in C# 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.