Skip to content

Commit

Permalink
correct IO's flatMap method (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
philipschwarz authored and fommil committed Oct 7, 2018
1 parent 1293053 commit 068319e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/scala/chapter1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ object Runner {

final class IO[A] private (val interpret: () => A) {
def map[B](f: A => B): IO[B] = IO(f(interpret()))
def flatMap[B](f: A => IO[B]): IO[B] = f(interpret())
def flatMap[B](f: A => IO[B]): IO[B] = IO(f(interpret()).interpret())
}
object IO {
def apply[A](a: =>A): IO[A] = new IO(() => a)
Expand Down

0 comments on commit 068319e

Please sign in to comment.