Monad transformers down to earth
summary
Explains why monads don’t compose generically and shows the practical trick of wrapping F[G[A]] to get a usable monad instance, then replaces that boilerplate with Cats’ OptionT and EitherT to compose Future[Option[A]] and Future[Either[Err,A]] at the leaves. Demonstrates helpers like liftT and pulling the raw value with dot.value, warns about extra allocations and brittle, deep stacks, and recommends local transformer use or alternatives (Free monads, Tagless Final / F) rather than app-wide transformer stacks.
AI-written summary · about
chapters (34)
- 0:00Introduction
- 1:19About this talk
- 2:19About the question
- 2:49The reasonable answer
- 3:42Category theory
- 4:13Functor
- 5:19Future
- 6:44WeCats
- 7:13Cats
- 7:55Lists
- 8:51Flatmap
- 24:01OptionT
- 24:38Generalization
- 25:15Metaphors
- 25:39GetUser
- 27:28Making the types fit
- 27:57Helpers
- 28:39Recap
- 29:21User exists
- 29:53Code dates
- 30:03Future of none
- 30:20Details errors
- 30:40Either
- 31:26MyErrorCase
- 32:45Not a silver bullet
- 33:52Personal tips
- 34:44Tragic Example
- 35:15Keep them for yourself
- 35:44Memory footprint
- 36:14Local optimization
- 37:33Other takeaways
- 38:25Free Mona
- 39:27F
- 41:19Questions
related talks
29mPRACTICAL MONAD TRANSFORMERS
01h 07mMonad transformers are good, actually
45mHOW I UNDERSTOOD MONAD TRANSFORMERS
24mUsing Monad Transformers without understanding them
44mIO monad & Error management: From Exceptions to Cats MTL
32mExtending your HTTP library with monad transformers
34mMonad Transformer State
46mOptimusPrimeT
