HOW I UNDERSTOOD MONAD TRANSFORMERS
summary
Mixing Future[Option[A]] in for-comprehensions becomes concrete: code shows a custom wrapper that maps and flatMaps the inner Option rather than the outer Future, then generalizes to a parametric OptionT using Functor/FlatMap/Applicative typeclass instances (cats) and implicits. The live coding reveals the need for an ExecutionContext for Future instances, how to lift/pure values, and tradeoffs: extra allocations hurt tight loops and don’t belong in public APIs if hiding cats types.
AI-written summary · about
chapters (13)
- 0:00Introduction
- 1:03Example
- 5:58Implicit Switch
- 8:27Effect Type
- 10:06Internal Wrapper
- 14:28Future Wrapper
- 27:50Implicit
- 28:42Functor
- 30:32Flat Map
- 32:45Applicative
- 35:28Dependency
- 37:28OptionT
- 39:18Compiler Error
related talks
29mPRACTICAL MONAD TRANSFORMERS
47mMonad transformers down to earth
46mOptimusPrimeT
43mSurviving a world overflowing with effects
32mExtending your HTTP library with monad transformers
35mThe Functor, Applicative, Monad talk
43mFree monad or tagless final? How not to commit to a monad too early
44mIO monad & Error management: From Exceptions to Cats MTL
