Errata

Parallel and Concurrent Programming in Haskell

Errata for Parallel and Concurrent Programming in Haskell

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. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.

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

Version Location Description Submitted By Date submitted Date corrected
Other Digital Version
ch 4.
footnote 11

The footnote describes "I-Structures, a concept from an early Parallel Haskell variant called pH."

In fact I-Structures date to pH's predecessor Id (c.f. http://ecommons.library.cornell.edu/handle/1813/6650) . I would perhaps change the footnote to describe "a concept from Id, an implicitly parallel functional language developed at MIT"

Note from the Author or Editor:
The suggestion is correct.

Gershom Bazerman  Jul 24, 2013 
ePub
Page Using Sample Code

when trying to compile with ghc 7.6.3
Preprocessing executable 'fwaccel' for parconc-examples-0.3...
[1 of 1] Compiling Main ( fwaccel.hs, dist/build/fwaccel/fwaccel-tmp/Main.o )

fwaccel.hs:44:14: Not in scope: `A.min'

i know this was tested with a previous version but there was talk about keeping sources up to date

Note from the Author or Editor:
I've uploaded 0.3.2 with the fix for this.

greg nwosu  Dec 23, 2013 
PDF
Page 4
Sample code section

The text says that I should run:

cabal install --only-dependencies
cabal build

At least in my machine (cabal-install version 1.16.0.2, Haskell Platform 2013) it required to configure first:

cabal install --only-dependencies
cabal configure
cabal build

Note from the Author or Editor:
Correct, insert "cabal configure" before "cabal build". Sorry about that.

Miguel Alcon  Jul 20, 2013 
Printed
Page 4
Sample code

I downloaded the sample code and tried to do a build but got the following error message:

setup.exe: The package has a './configure' script. This requires a Unix
compatibility toolchain such as MinGW+MSYS or Cygwin.
cabal: Error: some packages failed to install:
accelerate-0.14.0.0 failed during the configure step. The exception was:
ExitFailure 1
accelerate-io-0.14.0.0 depends on accelerate-0.14.0.0 which failed to install.

I'm running v 2013.2.0.0 under Windows 7 (64-bit), and v 0.3 of the sample code. Does this mean the sample code requires me to install MinGW/MSYS to work? The Haskell compiler, etc., seem to be working OK.

Thanks.

Note from the Author or Editor:
I haven't personally tried to install accelerate on Windows, but according to the instructions it should be possible: https://github.com/AccelerateHS/accelerate/wiki/Quick-Tour

If you don't manage to get it working by following those instructions, please contact the authors of accelerate (link on that page), and CC me so I can update this answer.

David Kettle  Jan 25, 2014 
Printed
Page 4
Sample Code

I downloaded the NVIDIA CUDA thing but when I tried to install it, I got the message "This graphics driver could not find compatible graphics hardware. You may continue installation, but you will not be able to run CUDA applications." So I take it that 1. MinGW/MSYS is required to run the sample programs under WIndows. 2. NVIDIA graphics hardware is also required (I have an ATI Radeon HD 4200). I didn't bother going any further, since I figured it would just be a waste of time. If these really are requirements to run the sample code, maybe you should add a note to that effect, so other people won't have to waste their time. BTW, I couldn't find any email addresses for the authors of CUDA on the web site, but I didn't spend a lot of time looking either.

Note from the Author or Editor:
Accelearate only supports CUDA at the present time, which is limited to NVIDIA GPUs. There is a work-in-progress OpenCL backend for Accelerate which would allow it to work with AMD GPUs too, but as I understand it this is not working yet.

David Kettle  Jan 28, 2014 
ePub
Page 7
2nd paragraph

Says ?Chapters 4, 5, 6, and pass:[ 14 cover frameworks that were developed in the last few years.?

Note from the Author or Editor:
Delete "pass:["

Anonymous  Jul 17, 2013 
PDF
Page 12
Figure 2-3

The drawing shows:

y -----> (,)

but it should be z (Based on the code)

Note from the Author or Editor:
The label in the diagram should say "z" not "y". The text changed at some point and I forgot to update the diagram.

Miguel Alcon  Jul 20, 2013 
Printed
Page 27
bottom of page

Shouldn't it say "... by adding the following (see sudoku4.hs)" rather than "sudoku3.hs"?

Note from the Author or Editor:
Yes, the sentence beginning "We can experiment with forcing..." should refer to sudoku4.hs, and not sudoku3.hs.

David Kettle  Feb 10, 2014 
PDF
Page 33
1st program listing

the listing containing evalPair is titled "strat.hs", but it should be "strat2.hs".
I'm using parconc-examples 0.3.4.

Note from the Author or Editor:
Correct - at the top of page 33, "strat.hs" should be "strat2.hs".

Anonymous  Oct 12, 2014 
PDF
Page 41
2nd paragraph from the bottom (right before code)

"instead of steps" should read "instead of step", there were no function "steps" in sequential version.

Note from the Author or Editor:
On page 41, the text "and we call parSteps_strat instead of steps" should read "and we call parSteps_strat instead of step".

Vitaly Bragilevsky  Mar 17, 2014 
PDF
Page 63
Last paragraph

Text says "The map is over the outer IntMap of the Graph, so there will be as many tasks as there are vertices without edges", but it should be "with edges".

Note from the Author or Editor:
Yes, "without edges" should be "with edges".

Vitaly Bragilesvky  Dec 02, 2013 
PDF
Page 64
footnote 2

Module name should be Control.Applicative instead of Control.Monad.Applicative.

Note from the Author or Editor:
Well spotted, it should indeed be Control.Applicative.

Vitaly Bragilevsky  Dec 02, 2013 
PDF
Page 99
the formula of rotation

If I am correct, the θ is anti-clockwise as postive and y-axis direction is bottom up(I think this is what in DevIL, not top down), then the rotation formula should be(Note the minus):

x' = - y sin θ + x cos θ
y' = y cos θ + x sin θ

And this also match the code(which view theta as the angle that rotate the new point back to old point, so image will rotate clockwise).

Note from the Author or Editor:
Correct, there is a missing minus sign. Rearranging the formulae to match the code, they should read:

x' = x cos \theta - y sin \theta
y' = x sin \theta + y cos \theta

where \theta is the Greek theta symbol.

Yu Changyuan  Feb 19, 2014 
PDF
Page 110
6th paragraph

In:

"The result is a DIM2 value in the Haskell world, so we can pattern match against Z:.x:.y to extract the x and y values, both of type Exp Int"

"Z:.x:.y" should read "Z:.y:.x"

Simon Marlow
Simon Marlow
 
Jun 17, 2014 
PDF
Page 115
Command line for "Running on the CPU" section

In "ghc -O2 fwaccel.hs -threaded" and "./fwaccel 2000 +RTS -s", replace "fwaccel" with "fwaccel-gpu" to agree with the GitHub example file as well as with the leading paragraph "A version of the shortest paths program that has this is in fwaccel-gpu.hs".

(Thanks for the awesome book & code!)

Note from the Author or Editor:
Correct - in the two command lines mentioned, "fwaccel" should be "fwaccel-gpu".

Audrey Tang  Jul 22, 2013 
PDF
Page 121
5th and 4th lines from the bottom

Code description mentions value "depth" while in code it is "max_depth".

Note from the Author or Editor:
Correct, the text should say "max_depth" and not "depth".

Vitaly Bragilevsky  Jan 18, 2014 
PDF, Other Digital Version
Page 150
bottom of the page

The implementation of "finally" has wrong types: the last line can't be "after" which is of type "IO b".

Code from the book:
===========
finally :: IO a -> IO b -> IO a
finally io after = do
io `onException` after
after

Fixed:
===========
finally :: IO a -> IO b -> IO a
finally io after = do
r <- io `onException` after
after
return r

Note from the Author or Editor:
Correct: the definition of finally on page 150 should read

finally :: IO a -> IO b -> IO a
finally io after = do
r <- io `onException` after
after
return r

Oleksandr Shyshko  Sep 13, 2014 
PDF
Page 157
3rd paragraph

There should not be an extra ")" after the sentence: "The ThreadKilled exception is provided by the Control.Exception library and is typically used for cancelling threads in this way.)".

Note from the Author or Editor:
The ")" at the end of the third paragraph on page 57 is superfluous.

Yu Changyuan  Feb 19, 2014 
Printed
Page 158
code sample after 3rd paragraph under "Masking Asynchronous Exceptions"

The implementation of "problem" uses "throw" but should use "throwIO", in accordance with the recommendation at the top of page 150.

Note from the Author or Editor:
Yes, I agree throwIO would be better than throw here.

Steven Taschuk  Nov 07, 2014 
PDF
Page 161
2nd paragraph from the bottom

There is no "cas", mentioned in the description, in the code above. It should be "casMVar" instead.

Note from the Author or Editor:
Yes, the two occurrences of "cas" should be "casMVar".

Vitaly Bragilevsky  Jan 25, 2014 
PDF
Page 164
2nd paragraph from the top

Variable name "old_hole" in the description and "oldHole" in the code.

Note from the Author or Editor:
Yes, "old_hole" in the text should be "oldHole". The code was modified at some point and I forgot to update the text.

Vitaly Bragilesvky  Jan 27, 2014 
PDF
Page 182
first source code example

Incorrect filename "code/tmvar.hs". It should be just "tmvar.hs".

Note from the Author or Editor:
On page 182, the filename for the first code sample should be "tmvar.hs", not "code/tmvar.hs".

Vitaly Bragilevsky  Mar 21, 2014 
Printed
Page 198
Definition of withAsync

Defining withAsync using bracket leaves the asynchronous thread in a masked state (prevailing from bracket). The Async library codes withAsync by hand using mask, so produces a different result. Concretely, on my machine:

import Control.Concurrent.Async
import Control.Exception

wa :: IO a -> (Async a -> IO b) -> IO b
wa io inner = bracket (async io) cancel inner

test :: IO ()
test = do
wa (getMaskingState >>= putStrLn.show) $ \a -> wait a
withAsync (getMaskingState >>= putStrLn.show) $ \a -> wait a

produces:

MaskedInterruptible
Unmasked

as output. I'm assuming this is not the intended semantics.

Note from the Author or Editor:
Yes, this is a good point. A correct definition of withAsync would be:

withAsync :: IO a -> (Async a -> IO b) -> IO b
withAsync io cont = do
var <- newEmptyTMVarIO
mask $ \restore -> do
t <- forkIO (try (restore io) >>= atomically . putTMVar var)
let a = Async t var
restore (cont a) `finally` cancel a

Richard Lupton  Jan 15, 2016 
Printed, PDF, ePub, Mobi
Page 201
Third bullet point

The sentence "The parent chooses whether to wait for a result from both children or just one, by using race or concurrently, respectively." should read "The parent chooses whether to wait for a result from both children or just one, by using concurrently or race, respectively."

Simon Marlow
Simon Marlow
 
Jun 04, 2014 
PDF
Page 251
source code from distrib-ping/ping-multi.hs, line (3)

a) Missing space between "forM_" and "ps".
b) Missing description of this line in the following list.

Note from the Author or Editor:
Unfortunately this mistake was accidentally introduced late in the production cycle while fixing some problems with syntax highlighting.

* There should be a space between forM_ and ps
* Point (3) should be (4), and (4) should be (5)
* Point (3) should read "Send the Ping message to each of the subprocesses"

Vitaly Bragilesvky  Feb 04, 2014 
PDF
Page 252
Last paragraph of section

[Node] should be [NodeId].

Note from the Author or Editor:
[Node] should read [NodeId]

Vitaly Bragilesvky  Feb 04, 2014 
Printed, PDF
Page 254
The paragraph after the type signatures

In this sentence:

"A typed channel consists of two ports, a SendPort and a ReceivePort. Messages are sent to the SendPort by sendChannel and received from the ReceivePort using receiveChannel"

"sendChannel" should be "sendChan"
"receiveChannel" should be "receiveChan"

Simon Marlow
Simon Marlow
 
Jun 12, 2014 
PDF
Page 256
4th paragraph

The last sentence of second from last paragraph say that "remote" framework explicitly disallow it, maybe should be "distributed-process" framework.

Note from the Author or Editor:
On page 256, second last paragraph, the text "So the remote framework explicitly disallows it" should read "So the distributed-process framework explicitly disallows it".

Yu Changyuan  Mar 31, 2014