Skip to Content
Learning Functional Programming in Go
book

Learning Functional Programming in Go

by Lex Sheehan
November 2017
Intermediate to advanced
670 pages
17h 35m
English
Packt Publishing
Content preview from Learning Functional Programming in Go

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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning Functional Programming

Learning Functional Programming

Jack Widman

Publisher Resources

ISBN: 9781787281394Supplemental Content