Susan Harkins (406) [Avatar] Offline
#1
Please post errors found in Functional Programming in C# here. If necessary, we'll publish a comprehensive list for everyone's convenience. Thank you!

Susan Harkins
Errata Editor
516926 (1) [Avatar] Offline
#2
Hi,

First of all, congratulations to the team that brought this book out - it's excellent!

I just started reading the book and noticed a minor error in section 3.1.2 How informative is a signature?.
In the paragraph that starts with 'Take a minute and see ...', a portion of a sentence reads, 'The function returns a list of T's as input; ...' when it should actually read 'The function returns a list of Ts as output; ...'.

I'll try and report any more that I find.

Thank you
152361 (1) [Avatar] Offline
#3
In the page 21 there is content duplicated, the same text appears in a paragraph and as page note

and use it to perform a task or to compute a value. [7] This is perhaps the most common pattern for HOFs, and it’s sometimes referred to as inversion of control: the caller of the HOF decides what to do by supplying a function, and the callee decides when to do it by invoking the given function.

7This is perhaps the most common pattern for HOFs, and it’s sometimes referred to as inversion of control: the caller of the HOF decides what to do by supplying a function, and the function decides when to do it by invoking the given function.
Enrico Buonanno (104) [Avatar] Offline
#4
On page 153

public static Func<T2, T3, R> Apply<T1, T2, T3, R> 
(this Func<T1, T2, T3, R> f, T1 t1) 
   => (t2, t3) => func(t1, t2, t3); 


should be:

public static Func<T2, T3, R> Apply<T1, T2, T3, R> 
(this Func<T1, T2, T3, R> f, T1 t1) 
   => (t2, t3) => f(t1, t2, t3);


the function passed as argument is called `f`, so in the implementation it should also be `f`, but is erroneously referred to as `func` in the text
Brother Bill (16) [Avatar] Offline
#5
Chapter 4.2 ForEach&lt;T&gt; won't compile (with fix)
On page 86, this code won't compile.

  public static IEnumerable<Unit> ForEach<T>(
      this IEnumerable<T> ts,
      Action<T> action) =>
      ts.Map(action.ToFunc()).ToImmutableList();


The error is on line 4 with message:
Cannot implicitly convert type 'System.Collections.Immutable.ImmutableList<System.ValueTuple>' to 'System.Collections.Generic.IEnumerable<LanguageExt.Unit>'
Cannot convert expression type 'System.Collections.Immutable.ImmutableList<()>' to return type 'System.Collections.Generic.IEnumerabli<LanguageExt.Unit>'

The cause was leaving out this line:
using Unit = System.ValueTuple;


Since it bit me for about a half hour, I figured that I would pass it on for your benefit.
Brother Bill (16) [Avatar] Offline
#6
Typo on page 87
Near top of page:
public static Option<Unit> ForEach<T>
    (this Option<T> opt, Action<T> action) 
    => Map(opt, action.ToFunc());


It should be:
public static Option<Unit> ForEach<T>
    (this Option<T> opt, Action<T> action) 
    => opt.Map(action.ToFunc());
MrYossu (7) [Avatar] Offline
#7
Small error, but repeated many times: When referring to a generic type, usually T, pluralising it should not include an apostrophe.

Therefore, the following text (page 81) is incorrect...

Map maps a list of T's to a list of R's by applying...

...and should read...

Map maps a list of Ts to a list of Rs by applying...

Not a major issue, but annoying to those of us who were taught correct grammar!

The same applies to abbreviations by the way. Haven't seen any in this book, but it's common to see "I bought two CD's today" which is incorrect for the same reason. Should just be "CDs"

End of rant smilie
157088 (1) [Avatar] Offline
#8
Hi Enrico,

you wrote a greate book!


I found a small issue on Page 69 in Listing 3.5:

public static Option.Some<T> Some<T>(T value) => new Option.Some<T>(value);


should be

public static Option<T> Some<T>(T value) => new Option.Some<T>(value);



Best Regards
Robert
Enrico Buonanno (104) [Avatar] Offline
#9
Typo on page 87
Brother Bill wrote:Near top of page:
public static Option<Unit> ForEach<T>
    (this Option<T> opt, Action<T> action) 
    => Map(opt, action.ToFunc());


It should be:
public static Option<Unit> ForEach<T>
    (this Option<T> opt, Action<T> action) 
    => opt.Map(action.ToFunc());


Strictly speaking, this is not an error, since both are equivalent (extension methods can be invoked as normal methods as well... )

However, I agree that I use the extension method syntax in the book (I find it more intuitive), so that it would be more consistent to change the next edition as suggested here
Enrico Buonanno (104) [Avatar] Offline
#10
157088 wrote:
I found a small issue on Page 69 in Listing 3.5:

public static Option.Some<T> Some<T>(T value) => new Option.Some<T>(value);


should be

public static Option<T> Some<T>(T value) => new Option.Some<T>(value);



Robert


Correct, thanks!
Susan Harkins (406) [Avatar] Offline
#11
"Small error, but repeated many times: When referring to a generic type, usually T, pluralising it should not include an apostrophe."

This is really more about style than grammar. While, I wasn't the copyeditor, I can offer an opinion. I reviewed the section in question and the author mentions a collection name, ts -- lower case. It's possible that the copyeditor chose to add the apostrophe to avoid confusion between ts and Ts. Doing so is allowable. But, I'm just guessing.

Susan Harkins
Errata Editor
Susan Harkins (406) [Avatar] Offline
#12
An updated errata list for Functional Programming in C# is available at https://manning-content.s3.amazonaws.com/download/e/c4f9ace-37af-4e6d-a598-782e97f8e407/Buonano_FuctionalProgramminginCSharp_err2.html. Thank you for participating in the collection process. Your contributions are a great help to us and other readers.

Regards,
Susan Harkins
Errata Editor
Tyson Williams (8) [Avatar] Offline
#13
Can this errata go meta?? smilie

Susan Harkins wrote:An updated errata list for Functional Programming in C# is available at https://manning-content.s3.amazonaws.com/download/e/c4f9ace-37af-4e6d-a598-782e97f8e407/Buonano_FuctionalProgramminginCSharp_err2.html. Thank you for participating in the collection process. Your contributions are a great help to us and other readers.

Regards,
Susan Harkins
Errata Editor


Hello Susan. Unfortunately, there is an mistake in the errata.

Enrico Buonanno wrote:
157088 wrote:
I found a small issue on Page 69 in Listing 3.5:

public static Option.Some<T> Some<T>(T value) => new Option.Some<T>(value);


should be

public static Option<T> Some<T>(T value) => new Option.Some<T>(value);



Robert


Correct, thanks!


Robert's observation was not properly copied to your errata list. All six occurrences of the three character sequence (1) left angle bracket, (2) T, (3) right angle bracket seem to have been swallowed by the HTML. I see the characters in the page source but not in the rendered page. My guess is that you need to escape the angle brackets:
https://stackoverflow.com/questions/14659240/angle-bracket-without-triggering-html-code

If it matters, I am seeing this mistake in the errata list using Google Chrome 71.0.3578.98 on Windows 10.
Tyson Williams (8) [Avatar] Offline
#14
On page 180, I think the line
Apply : (T1 → T2 → R) → T1 v (T2 → R)

should be
Apply : (T1 → T2 → R) → T1 → (T2 → R)
Tyson Williams (8) [Avatar] Offline
#15
On page 196, Listing 8.17 itself as well as the the text before it are not perfectly consistent. The text before the listing and a string in the listing say that valid numbers are positive numbers but the conditions in the two
where
clauses check for
a >= 0
and
b >= 0
respectively.

It would be more precise for the conditions to be strengthened to
a > 0
and
b > 0
respectively.

Alternatively, the two occurrences of "positive" could be replaced with "nonnegative" since the Pythagorean theorem still holds in this case. However, I don't recommend this alternative. In addition to giving the reader an opportunity to consider unnecessary details of the motivating example, the text introduces this example by way of triangles, but the Pythagorean equation no longer describes a triangle in those edge cases (instead it describes a line when exactly one "side" has length 0 and a point when both "sides" have length 0).
Enrico Buonanno (104) [Avatar] Offline
#16
Listing 8.21 "Implementation of Bind for Validation" should read:

public static Validation<R> Bind<T, R>
   (this Validation<T> val, Func<T, Validation<R>> f)
   => val.Match(
      Invalid: (err) => Invalid(err),
      Valid: (t) => f(t));


i.e.: on the last line, the inner value should be called `t`, since it is of type `T`, for consistency with the naming patterns used throughout the book
Enrico Buonanno (104) [Avatar] Offline
#17
Tyson Williams wrote:On page 180, I think the line
Apply : (T1 → T2 → R) → T1 v (T2 → R)

should be
Apply : (T1 → T2 → R) → T1 → (T2 → R)



Correct, thanks!
Enrico Buonanno (104) [Avatar] Offline
#18
Tyson Williams wrote:On page 196, Listing 8.17 itself as well as the the text before it are not perfectly consistent. The text before the listing and a string in the listing say that valid numbers are positive numbers but the conditions in the two
where
clauses check for
a >= 0
and
b >= 0
respectively.

It would be more precise for the conditions to be strengthened to
a > 0
and
b > 0
respectively.

Alternatively, the two occurrences of "positive" could be replaced with "nonnegative" since the Pythagorean theorem still holds in this case. However, I don't recommend this alternative. In addition to giving the reader an opportunity to consider unnecessary details of the motivating example, the text introduces this example by way of triangles, but the Pythagorean equation no longer describes a triangle in those edge cases (instead it describes a line when exactly one "side" has length 0 and a point when both "sides" have length 0).


I'd rather not make any changes in this case, because I'd like the code to work even in the edge case, as it should, and I want the text to read as simply as possible ("positive" is easier to read then "nonnegative"). I also don't think it's inaccurate; you seem to think that zero is neither positive nor negative; I tend to think of zero as both positive and negative; both these conceptions are used in mathematics (according to a quick google search). Also frankly the example is meant to be very pedestrian so it's not worth splitting hairs.
Tyson Williams (8) [Avatar] Offline
#19
Enrico Buonanno wrote:Listing 8.21 "Implementation of Bind for Validation" should read:

public static Validation<R> Bind<T, R>
   (this Validation<T> val, Func<T, Validation<R>> f)
   => val.Match(
      Invalid: (err) => Invalid(err),
      Valid: (t) => f(t));


i.e.: on the last line, the inner value should be called `t`, since it is of type `T`, for consistency with the naming patterns used throughout the book


And doubly so since the book currently uses "r", which suggests that it is of type "R"! I can't believe I didn't notice this. I have been reading and rereading this part.
Enrico Buonanno (104) [Avatar] Offline
#20
Listing 8.12, on the right side, there should be a linebreak before `orderby` (this is a typographic rather than syntactic error: the code was meant to be laid out to show the correspondence between the left and right side)
Enrico Buonanno (104) [Avatar] Offline
#21
listing 10.13, line 15 currently reads:

.TakeWhile(e => endOfPeriod < e.Timestamp);


but should read:

.TakeWhile(e => e.Timestamp < endOfPeriod);

Enrico Buonanno (104) [Avatar] Offline
#22
section 8.2 the second code snippet should read:

public static Option<R> Apply<T, R>
   (this Option<Func<T, R>> optF, Option<T> optT)
   => optT.Bind(t => optF.Bind(f => Some(f(t))));


as rightly pointed out in https://forums.manning.com/posts/list/45375.page#p126542