Core concept

for {
  a <- Some(1)
  b <- Some(2) if b > 0
} yield a + b  // Some(3)
Advertisement

How it works

Only works with types having flatMap/map/withFilter. Consistent monad type needed.

Advertisement

Trade-offs + gotchas

Multi-step monadic composition. Async workflows.