Errata

Learn You a Haskell for Great Good!

Errata for Learn You a Haskell for Great Good!

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
na
NA


In the chapter of your book, "Learn You A Haskell", there is a mistake at the start of the topic, "I'm a list comprehension". The set of the first ten even natural numbers is given as an example to start this topic however, the set notation given here is that of a set of first 20 natural numbers.[cid:4f517ef8-beb0-4ce3-a5df-66bdc9dc494e]
For the set to be of first ten natural numbers x must be less than or equal to 5, rather than 10.

Anonymous  Jan 28, 2019 
PDF Page 41
first bmi function type declaration

The correct type declaration is either

bmiTell :: Double -> String

or

bmiTell :: (RealFloat a) => a -> String

as in the online version

Anonymous  Oct 04, 2011 
PDF Page 99
Second code block. findKey Function

the function definition:

findKey key ((k,v):xs)
| key == x = Just v
| otherwise = findKey key xs

This will give an error at compile:
Not in scope: `x'

Should be

findKey key ((k,v):xs)
| key == k = Just v
| otherwise = findKey key xs

Bruce W. Lowther  Apr 30, 2011 
Printed Page 140
First paragraph in Subclassing section

Text states "The class declaration for Num is a bit long...". It then gives the definition of Ord. Based on the context, I believe Ord is correct.

Darren Danvers  Oct 18, 2020 
Other Digital Version 187
Listing at end of page (Kindle edition)

The todo program needs to import Control.Exception to make use of bracketOnError.

Anonymous  Sep 23, 2011 
Other Digital Version 188
Todo program's remove function

The remove function contains code to output a menu of todo items as in the interactive version, but this menu is not needed in the non-interactive version and is not shown in the example output.

Replace ...


let todoTasks = lines contents
numberedTasks = zipWith (\n line -> show n ++ " - " ++ line)
[0..] todoTasks
putStrLn "These are you TO-DO items:"
mapM_ putStrLn numberedTasks
let number = read numberString
newTodoItems = unlines $ delete (todoTasks !! number) todoTasks


... with ...

let todoTasks = lines contents
number = read numberString
newTodoItems = unlines $ delete (todoTasks !! number) todoTasks

Anonymous  Sep 23, 2011 
PDF Page 189
code at top

(\(tempName, tempHandle) -> do
hPutStr tempHandle newTodoItems hClose tempHandle removeFile "todo.txt" renameFile tempName "todo.txt")

Instead of "todo.txt' it should be filename

also and "import Control.Exception" needs to be added.

Richard Ferrante  Aug 20, 2011 
Other Digital Version 273
Kindle Location 7162

"Next up, we have >>=." should read "Next up, we have >>".

Anonymous  Dec 09, 2011 
323
in the LeftM section

In the examples it says "ghci> runWriter $ liftM not $ Writer (True, "chickpeas")"

Instead, the "Writer" part should be lowercase, as in "ghci> runWriter $ liftM not $ writer (True, "chickpeas")"

Michael Levine  Feb 08, 2017 
342
The section for setting up the "instance Monad Prob where"

Due to changes in the GHC compiler, you also need to include the following code to make the newtype Prob work properly as a Monad:


import Control.Applicative

instance Applicative Prob where
pure x = Prob [(x, 1%1)]
(<*>) = ap

More details on this change can be found at the following two links:

http://stackoverflow.com/questions/31652475/defining-a-new-monad-in-haskell-raises-no-instance-for-applicative

https://wiki.haskell.org/Functor-Applicative-Monad_Proposal

Michael Levine  Feb 09, 2017