Functional Programming, Simplified book cover

Hi, my name is Alvin Alexander. I wrote the Scala Cookbook for O’Reilly, and this book — Functional Programming, Simplified — is my new book about functional programming (FP).

When I first started trying to learn about FP in Scala, I struggled — a lot. Because Scala/FP developers use many advanced language features all at the same time, it took me a long time to break through that learning barrier. The only way I was finally able to understand FP was to break their code down into smaller chunks until I could understand each concept. When I finally broke through what turned out to be many barriers, I decided to turn my notes into a book that could help other people understand functional programming.

As just one small example of the barriers I’m talking about, when I first started learning FP I came across this code, which was introduced with the words, “it’s very easy to access and modify state”:

def updateHealth(delta: Int): Game[Int] =
     StateT[IO, GameState, Int] { (s: GameState) =>
     val newHealth = + delta
     IO((s.copy(player = s.player.copy(health = newHealth)), newHealth))

I don’t know about you, but the first time I saw that code, the word “easy” is not what came to mind. Among other things going on in that code, I had never written a type like StateT[IO, GameState, Int] and thought it was easy.

In this book I explain all of the concepts that are used to write FP code in Scala. As I learned in my own experience, once you understand all of the small programming concepts, you can understand Scala/FP.

Website navigation

To move between pages on this website, use the arrow keys on your keyboard or click the arrow images on screen. You can also use the navigation bar on the left to jump to individual lessons.

results matching ""

    No results matching ""