// === def add[R](i: Int, j: Int): Cont[R, Int] = Cont(ar => ar(i + j)) def mul[R](i: Int, j: Int): Cont[R, Int] = Cont(ar => ar(i * j)) def show[R](i: Int): Cont[R, String] = Cont(ar => ar(s"num: $i")) def prog[R]: Cont[R, String] = for { a <- add(1, 2) b <- mul(a, 3) s <- show(b) } yield { s.toUpperCase } // === scala> prog.run(s => s.toList) res18: List[Char] = List(N, U, M, :, , 9) scala> prog.run(s => s.length) res19: Int = 6 scala> prog.run(s => s) res20: String = NUM: 9 // === def prog[R]: Cont[R, String] = add(1, 2).flatMap { a => mul(a, 3).flatMap { b => show(b).map { s => s.toUpperCase } } }