Skip to content
0:00 / 0:00

#cats#statemonad#traverse

Destroy your foldLeft with traverse and State - Scala tutorial

Jakub Kozłowski

3.7K subscribers • 30 videos on Hallway

YouTube
  • Recommended by 1 person: 1 in engineering communities.
  • Presented by Jakub Kozłowski
  • Linked in the descriptionkubukoz/videos

Intermediate. Assumes working knowledge.

2.9K views5 years ago1 recommendation

Programming languagesSoftware designScalaFunctional programmingRefactoring and legacy code

Jakub Kozłowski demonstrates how to refactor complex foldLeft operations in Scala using the State monad and traverse from the Cats library.

In this video, I show how you can tame the complexity of an untamed foldLeft by replacing it with a traverse. If you enjoyed this video, please like and subscribe, and hit the bell icon so you don't miss another one ;) I'm on Twitter: twitter.com/kubukoz on GitHub: github.com/kubukoz sometimes stream on Twitch: twitch.tv/kubukoz And you can buy me a coffee if you want: ko-fi.com/kubukoz Read the code: github.com/kubukoz/videos/blob/main/traverse-with-state/src/… Table of contents: - Introduction - Overview of the example - Refactoring: splitting the function into steps - The limitation of function composition, State monad overview - Refactoring to the State monad - Using traverse - Further splitting of State transitions - Summary, parting words Useful links: My video on Traverse: youtube.com/watch?v=CSErp1mZodM State chapter in "Scala with Cats": scalawithcats.com/dist/scala-with-cats.html#the-state-monad State documentation in Cats: typelevel.org/cats/datatypes/state.html Red Book (functional programming in Scala) chapter on State: livebook.manning.com/book/functional-programming-in-scala/ch… Exercises for the Red Book: scala-exercises.org/fp_in_scala/pure_functional_state Herding Cats - State datatype: eed3si9n.com/herding-cats/State.html

Why it's here

1 person recommends this

u/kubukozcats,cats-effectin r/scala • Recommends

Destroy your foldLeft with traverse and State - Scala tutorial