14 Lazy computations, continuations, and the beauty of monadic composition

This chapter covers

  • Lazy computations
  • Exception handling with Try
  • Monadically composing functions
  • Escaping the pyramid of doom with continuations

In this chapter, you’ll first learn why it’s sometimes desirable to define lazy computations, functions that may or may not be evaluated. You’ll then see how these functions can be composed with other functions independently of their evaluation.

Once you’ve got your feet wet with lazy computations, which are just plain functions, you’ll see how the same techniques can be extended to computations that have some useful effect other than laziness. Namely, you’ll learn how to use the Try delegate to safely run code that may throw ...

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