Recursion pitfalls in IO monads and how to avoid them
Channel: Jakub Kozłowski
Date: 2021-11-08

Back after a sick break :) in this video, I'm talking about traps you can easily fall into when using any IO/Task effect/monad (or any monad, for that matter), and how to avoid them.

I'm on Twitter: https://twitter.com/kubukoz

on GitHub: https://github.com/kubukoz
sometimes stream on Twitch: https://twitch.tv/kubukoz

And you can buy me a coffee if you want: https://ko-fi.com/kubukoz

Read the code: 
https://github.com/kubukoz/videos/tree/main/io-recursion-pitfalls

0:00 - Introduction, overview
0:17 - OutOfMemoryError - example, explanation
6:56 - OOM - solutions
9:23 - StackOverflowError - example, explanation
13:01 - SOE - solutions
14:22 - Recursion tip: Defer.fix function
15:06 - Summary, parting words

Find out more:
Better Monadic For: https://github.com/oleg-py/better-monadic-for
IO tutorial: https://typelevel.org/cats-effect/docs/tutorial
Defer typeclass: https://github.com/typelevel/cats/blob/main/core/src/main/scala/cats/Defer.scala
Another example of a useful Defer instance in the context of `fix`: https://github.com/typelevel/cats-parse