"Here's my attempt at functional programming in Go. I think it's a good idea, but I'm really not sure."
I have seen comments like this on over a dozen blog articles. I hope that after reading this chapter and working through the examples, you'll have a new-found love for functional programming (FP). Not because it's so pure that you worry that side-effect programming will send you to hell, but rather, because you feel comfortable with concepts that form the basis of pure FP and you see that its benefits outweigh the costs of learning how to use it.
Our goals in this chapter are as follows:
- Appreciate how the lack of generics support in Go can be a good thing
- Learn how to use a generics code generation tool to solve the boilerplate problem
- Deeply understand how function composition works
- Build a few functors and understand how to map between worlds
- Build a few monoids and learn how to write your own reduce functions