|
|
|
|
|
by kagakuninja
1021 days ago
|
|
I'm using Scala syntax here... If I have: val a = IO(42)
def f(n: Int) = IO(n)
And I use map, then I get: val r: IO[IO[Int]] = a.map(f)
Which we don't want... the solution is to flatten it. This can be done with flatten, or flatMap: a.map(f).flatten
a.flatMap(f)
Both produce IO[Int], and this makes sense to me using any monad. By contrast, bind means nothing to me. |
|