-
Notifications
You must be signed in to change notification settings - Fork 3k
Errata
This page lists post-publication errata for the first published version of the book. If errata require code changes in this repo, please submit a GitHub issue. Otherwise, feel free to update this page directly. We will periodically process any issues submitted and keep this page up to date with all known errata.
Pg xviii in About this Book: URL is incorrectly listed as https://github.com/fpinscala/fpinscla (note missing 'a'), should be https://github.com/fpinscala/fpinscala
Pg 7: In throw new Exception
, Exception
should not be bolded, in the code listing at the top of the page.
Pg 10: URL in footnote is incorrectly listed as https://github.com/pchiusano/fpinscala, should be https://github.com/fpinscala/fpinscala
Pg 19: Parenthetical phrase in footnote is missing a closing parenthesis.
Pg 55: There is no field manager
in the Employee class. The correct definition should be:
case class Employee(name: String, department: String, manager: Option[Employee])
Pg 82: Int.MaxValue
is incorrectly capitalized as Int.maxValue
in the exercise prompt for 6.1
Pg 86: Definition of nonNegativeLessThan
at bottom of page incorrectly reuses rng
variable for recursive call. Definition should be:
def nonNegativeLessThan(n: Int): Rand[Int] = { rng =>
val (i, rng2) = nonNegativeInt(rng)
val mod = i % n
if (i + (n-1) - mod >= 0)
(mod, rng2)
else nonNegativeLessThan(n)(rng2)
}
Pg 74: Figure contains a typo, "strean elements" instead of "stream elements"
Pg 150: Listing 9.1 has a gratuitous nonstrict function argument in the definition of |
in ParserOps
. The definition should be:
case class ParserOps[A](p: Parser[A]) {
def |[B>:A](p2: Parser[B]): Parser[B] = self.or(p,p2)
def or[B>:A](p2: Parser[B]): Parser[B] = self.or(p,p2)
}
Pg 150: Examples given for listOfN
are incorrect. Should be:
run(listOfN(3, "ab" | "cad"))("ababcad") == Right(List("ab","ab","cad"))
run(listOfN(3, "ab" | "cad"))("cadabab") == Right(List("cad","ab","ab"))
run(listOfN(3, "ab" | "cad"))("ababab") == Right(List("ab","ab","ab"))
Pg 184: Exercise 10.13 incorrectly defines Leaf
as a case object
. It should be case class
:
case class Leaf[A](value: A) extends Tree[A]
Pg 187: Definition of signature for map
on Option
has incorrect return type, should be:
def map[A,B](oa: Option[A])(f: A => B): Option[B]
Pg 214: catch
block is missing a case
. Was:
} catch {
Failure("Birthdate must be in the form yyyy-MM-dd")
}
Should be:
} catch {
case (e: Exception) => Failure("Birthdate must be in the form yyyy-MM-dd")
}
Pg 235: The lazy val t
declaration in the definition of forever
shadows itself on recursive invocation. It should be:
def forever[A,B](a: F[A]): F[B] = {
lazy val t: F[B] = a flatMap (_ => t)
t
}
Pg 238: Definition of printLine
has a typo, an extra Return
constructor, should be:
def printLine(s: String): IO[Unit] = Suspend(() => println(s))
Pg 240: REPL session has a typo, should be:
val g = List.fill(100000)(f).foldLeft(f) {
(a, b) => x => Suspend(() => ()).flatMap { _ => a(x).flatMap(b)}
}
Note: we could write a little helper function to make this nicer:
def suspend[A](a: => IO[A]) = Suspend(() => ()).flatMap { _ => a }
val g = List.fill(100000)(f).foldLeft(f) {
(a, b) => x => suspend { a(x).flatMap(b) }
}
Pg 241: TrailRec
should be TailRec
at the top of the page.
Pg 262: List 14.3 STArray.apply
has a typo, should be:
object STArray {
def apply[S,A:Manifest](sz: Int, v: A): ST[S, STArray[S,A]] =
ST(new STArray[S,A] {
lazy val value = Array.fill(sz)(v)
})
}
Pg 275: Await
in the definition of loop
is incorrect. Should be await
.
Pg 285: Code snippet has an incorrectly named type parameter, currently reads:
case class Await[A,O](
req: Is[I]#f[A], recv: Either[Throwable,A] => Process[Is[I]#f,O]
) extends Process[Is[I]#f,R] // `R` should be `O`
Should read:
case class Await[A,O](
req: Is[I]#f[A], recv: Either[Throwable,A] => Process[Is[I]#f,O]
) extends Process[Is[I]#f,O]
All content on this wiki, including code and documentation, is licensed using the MIT license. Contributors to this wiki agree to license their contributions using the MIT license.