Book Image

Learning Functional Programming in Go

By : Lex Sheehan
Book Image

Learning Functional Programming in Go

By: Lex Sheehan

Overview of this book

Lex Sheehan begins slowly, using easy-to-understand illustrations and working Go code to teach core functional programming (FP) principles such as referential transparency, laziness, recursion, currying, and chaining continuations. This book is a tutorial for programmers looking to learn FP and apply it to write better code. Lex guides readers from basic techniques to advanced topics in a logical, concise, and clear progression. The book is divided into four modules. The first module explains the functional style of programming: pure functional programming, manipulating collections, and using higher-order functions. In the second module, you will learn design patterns that you can use to build FP-style applications. In the next module, you will learn FP techniques that you can use to improve your API signatures, increase performance, and build better cloud-native applications. The last module covers Category Theory, Functors, Monoids, Monads, Type classes and Generics. By the end of the book, you will be adept at building applications the FP way.
Table of Contents (21 chapters)
Title Page
Credits
About the Author
Acknowledgments
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface
Index

Business use case scenarios


The monad workflow provides a solution for business use case scenarios. If we work with a team that implements application features or manages tasks using use case scenarios, the steps in the monad workflow pipeline would likely correspond directly to our task’s requirements. Using this workflow could simplify testing, as well as development.

Here’s an example that requires five steps:  

Each requirement maps directly to a workflow step (as well as a test).

If we make it through the last step with no errors, then we downcast our data into a string. It will contain JSON and look something like this:

{
"car": {
"vin": "348543985AZDD",
"make": "Lexus",
"model": "IS 250",
"options": {
"option_1": "Stick Shift",
"option_2": "Moon Roof",
"option_3": "Leather"
}
  },
"timestamp": "20171030205535"
}