337111 (1) [Avatar] Offline
#1
Hi,

In section 13.3.1 of the book, the printLine function is implemented as follows:

def printLine(s: String): IO[Unit] =
  Suspend(() => Return(println(s)))

However, the definition of Suspend is as follows:

case class Suspend[A](resume: () => A) extends IO[A]

So, in the code above, the parameter to Resume should be a function that takes Unit and returns an A; not an IO[A], which Return is.

In other words, the implementation of printLine should be:

def printLine(s: String): IO[Unit] =
  Suspend(() => println(s))

Is my reasoning correct or am I missing something?
466742 (2) [Avatar] Offline
#2
It's in Errata. A typo error it says.