What else can Monads do?

Monads can be used to clearly convey our business logic and manage our applications processing flows and more.

You know what I'm talking about. Consider the following piece of code:

if err != nil {
return nil, fmt.Errorf("%s:%d: %v", sourceFile, sourceLine, err)
}

Those if err != nil  blocks litter our code and obscure our code's original intent. If this is our happy path code:

happy path code

This is what it looks like after we add error checking:

add error checking

Guess what our FP code would look like after including error handling?

FP code including error handling

How can this be? No inline error checking? We'll cover this topic in Chapter 9Functors, Monoids, and Generics.