Galy (2) [Avatar] Offline
#1
The code
val g = List.fill(100000)(f).foldLeft(f) {
(a, b) => x => Suspend(() => a(x).flatMap(b))
}
(ch. 13.3.2, page 240) does not compile, because the parameter to Suspend must be a "() => Int" and not a "() => IO[Int]".
It can't be corrected trivially, because with
"case class Suspend[A](resume: () => IO[A]) extends IO[A]" instead of
"case class Suspend[A](resume: () => A) extends IO[A]"
the interpreter can't be defined tail-recursive any longer.
pchiusano (36) [Avatar] Offline
#2
Re: Mistake in TailRec example
Thanks. You can submit issues like this on GitHub rather than this forum. I've opened an issue for it:

https://github.com/fpinscala/fpinscala/issues/308