ThatGuyDuncan (68) [Avatar] Offline
#1
I spent three years as a proofer, and I feel badly when I see something and don't report it. Is there a friendly way to provide such feedback?
Isaac Abraham (68) [Avatar] Offline
#2
Feel free to put it on here (or contact me directly if you don't feel comfortable doing it on the forum). Manning have their own proof readers I believe so will be doing that in due course as well, but I'm not complaining if you have noticed some issues (and I'm sure there are plenty).

Cheers

Isaac
ThatGuyDuncan (68) [Avatar] Offline
#3
0.1.4 (30.2): You could even start to reference the field elsewhere in your application, without the compiler preventing you for accessing it without having ever initialised it.
ThatGuyDuncan (68) [Avatar] Offline
#4
0.1.4 (31.1): You may feel that an instinctive negative reaction to what I’ve just told you
ThatGuyDuncan (68) [Avatar] Offline
#5
0.1.5 (32.2): It’s almost as though object-oriented languages with curly braces are apparently the only form of general purpose programming languages in existence!
Isaac Abraham (68) [Avatar] Offline
#6
What do the 0.1.4 (31.1) represent?
ThatGuyDuncan (68) [Avatar] Offline
#7
0.1.5 (32.2): The biggest challenges you’ll face is first learning the syntax of F#, and then, more importantly, unlearning the dogma of OO methodology.
ThatGuyDuncan (68) [Avatar] Offline
#8
Isaac Abraham wrote:What do the 0.1.4 (31.1) represent?


0.1.4 is what I take to be your section #
31.1 is the page #, as reported to me by my reader (currently reading in Calibre on a Windows 7 machine).

Is this useful, or just b!tchy? I don't want to bog you down....
ThatGuyDuncan (68) [Avatar] Offline
#9
0.2.1 (35.6): Instead, we’ll focus on a core subset of the language that you’ll find gives you the most effective bang for your investment; where there’s further learnings available that could be worthwhile for you, I’ll point it out.
ThatGuyDuncan (68) [Avatar] Offline
#10
what I see
[ 128 KB ]
Isaac Abraham wrote:What do the 0.1.4 (31.1) represent?
Isaac Abraham (68) [Avatar] Offline
#11
OK the section numbers (e.g. 0.1.4) are useful; the page numbers not so much smilie

BTW - The opening chapter is going to be revamped quite a bit, but this is definitely useful because some of it might be moved elsewhere in the book.
ThatGuyDuncan (68) [Avatar] Offline
#12
0.4.1: There’s channels of communication through twitter, hangouts, real world meetups, mailing lists and websites.
ThatGuyDuncan (68) [Avatar] Offline
#13
0.4.1: Part of this is drawn out of necessity - because Microsoft don’t invest quite as much in F# as, say C#...
ThatGuyDuncan (68) [Avatar] Offline
#14
0.4.1: Frankly, this attitude is something that the C# and VB .NET communities need to do as well in the future order to ensure that those languages (and associated libraries) evolve in the

italic and underline to identify different issues.
ThatGuyDuncan (68) [Avatar] Offline
#15
0.4.3: Again, this collaborative approach is something that might be complete foreign to you...
ThatGuyDuncan (68) [Avatar] Offline
#16
3.4 F# Scripts in Visual Studio

"You'll now be looking at a blank file in the main panel. Entering any text in here will give you full intellisense and code completion etc. just like inside a full fs file. Start by entering something simple into the REPL:"

I thought that the REPL was the F# Interactive window. In this case, the description that follows (hovering over "text") has no impact in the F# Interactive window, but it does in the newly-added script file. Does a script file qualify as a REPL?
ThatGuyDuncan (68) [Avatar] Offline
#17
Unit 2: Hello F#
"In this previous unit..."
ThatGuyDuncan (68) [Avatar] Offline
#18
4.1
"All the features you're going to see now and geared towards helping you achieve that."
ThatGuyDuncan (68) [Avatar] Offline
#19
4.2
"Here's some takeaways..."
"... and functions that take in zero or multiple arguments (as the per the add function)..."
"Create a simple one-line function that calls takes in no arguments..."

I note a difference in our English. I might say, "This function takes one argument" and you would likely say, "This function takes in one argument." Not a mistake, just a difference. Interesting, yes? smilie
ThatGuyDuncan (68) [Avatar] Offline
#20
4.3
"... you'll find that you can hide effectively values..."
"... whilst F# does cater for most of them..."
ThatGuyDuncan (68) [Avatar] Offline
#21
A large majority of what you’ve seen so far is simply “stripping away” a lot of what it turns out are largely unnecessary syntax features of C#, but some elements of the language will have been new to you, such as nested scopes and the lack of support for cyclic dependencies.
ThatGuyDuncan (68) [Avatar] Offline
#22
5.1
"Unless you’re only used one of the earliest versions of C#, you’ll almost certainly be familiar with the var keyword."
ThatGuyDuncan (68) [Avatar] Offline
#23
Listing 5.2
var i = customer.Withdraw(50);          ? 
var newBalance = customer.Withdraw(50); ? 
?   Implicitly typed. Bar returns an int, so i is inferred to be an int.
?   Use of intelligent naming to explain intent to the reader.
Isaac Abraham (68) [Avatar] Offline
#24
ThatGuyDuncan wrote:3.4 F# Scripts in Visual Studio

"You'll now be looking at a blank file in the main panel. Entering any text in here will give you full intellisense and code completion etc. just like inside a full fs file. Start by entering something simple into the REPL:"

I thought that the REPL was the F# Interactive window. In this case, the description that follows (hovering over "text") has no impact in the F# Interactive window, but it does in the newly-added script file. Does a script file qualify as a REPL?


Good spot - fixed. It should have said script rather than REPL.
Isaac Abraham (68) [Avatar] Offline
#25
Thanks for all of these - have made all fixes for everything identified so far. Thanks again.
ThatGuyDuncan (68) [Avatar] Offline
#26
How do you want to handle these? You could delete each post as you fix 'em, I could start a new thread for v4, or is there an easier plan?
ThatGuyDuncan (68) [Avatar] Offline
#27
Priming Exercise: Practical Benefits of Type Inference [dam: no section #, should there be one?]
Even in its restricted form in C#, type inference can be like quite a nice feature.
ThatGuyDuncan (68) [Avatar] Offline
#28
Type annotations in C# and F#
Many C# developers recoil when they see types declared after the name of the value. In fact, most languages outside of C / C++ / Java / C# use this pattern. It’s particularly common in languages like F# where type inference is particularly powerful, or optional type systems like Typescript.
ThatGuyDuncan (68) [Avatar] Offline
#29
5.3   Type Inference with F#
This is another feature of the type system that helps enforce safety and correctness, although it’s not something that you’ll necessarily be used it.
ThatGuyDuncan (68) [Avatar] Offline
#30
5.4.1   Working with the BCL
We’ve not looked at F# types yet, so this won’t mean much to you yet...
ThatGuyDuncan (68) [Avatar] Offline
#31
5.4.3   Cyclical Dependencies
Not necessarily a limitation of type inference, but cyclical dependencies are also an enabler for type inference as the compiler uses this “restriction” to make decisions regarding type inference.

I just am not sure what you're trying to tell me here. I thought Cyclical dependencies were disallowed by the compiler... are you explaining another reason why type inference isn't perfect, or...?

Italics to highlight repetition.
ThatGuyDuncan (68) [Avatar] Offline
#32
5.5   Type Inferred Generics

Listing 5.8 Inferred type arguments in F#
?   Creating a generic List, omitting the type argument out

"So the call to numbers.Add(10) if used to tell the compiler that the List is of type int."

"In this example, there’s no type specified for output anywhere in the code – so the compiler can’t infer the type of List. In this case, it will simply make the entire createList() function generic!" (underlined should be in 'code' format/font, yes?)
ThatGuyDuncan (68) [Avatar] Offline
#33
5.6   Following the breadcrumbs

"Now you try
Copy this code into an F# script in VS; everything will compile by default." [it doesn't, and the graphic shows the error]

Figure 5.3
Here, where you want us to cut & paste, it's a graphic -- we can't cut & paste.

"Why is this? This is what I refer to as “following the breadcrumbs” – you’ll need to track through at least one of the errors and see the inferred types to understanding why this has happened."
ThatGuyDuncan (68) [Avatar] Offline
#34
5.7   Summary
"It’s well worth us spending the time to understand type inference in F#, because it’s a crucial part of “flavour” of the language..."
ThatGuyDuncan (68) [Avatar] Offline
#35
6.1.3   Accidentally sharing state
"Some time later you notice a bug in your application – the state of business object no longer looks like it did earlier on!"
ThatGuyDuncan (68) [Avatar] Offline
#36
6.1.4   Testing hidden state
"It turns out that working immutable data solves many of these problems in one fell swoop."
ThatGuyDuncan (68) [Avatar] Offline
#37
6.3   Working with mutable objects
"F# also has a shortcut for creating with mutable data structures in a way that assigns all properties in a single action..."
ThatGuyDuncan (68) [Avatar] Offline
#38
6.4.2   Working with immutable data
"So instead, we create copies of the state with updates applies, and return that back out for the caller to work with; that state may be passed in to other calls that generate new state yet again." ["yet again" seems redundant, yes?]

"This is because the the only values that can affect the result are supplied as input arguments...."
ThatGuyDuncan (68) [Avatar] Offline
#39
6.4.3   Other benefits of immutable data
"...but there are occasions where simply {by?} making your data read-only, the need to “hide” your data goes away."
"We’ll see more of this later, but one of the other benefits of working {with?} immutable data is that you don’t need to worry about locks within a multi{-?}threaded environment."
ThatGuyDuncan (68) [Avatar] Offline
#40
6.5   Summary
"You saw a simple example of how we create and working immutable data in F#"
ThatGuyDuncan (68) [Avatar] Offline
#41
7    Expressions and Statements
"Expressions and statements are two aspects of programming that we use often, and generally take for granted. In this lesson: -" {extraneous trailing hyphen crashing your exclusive party}
ThatGuyDuncan (68) [Avatar] Offline
#42
7.1   What are expressions and statements?
"In a nutshell, that’s it really." {"really" seems redundant}
"But how can we write applications when program flow constructs themselves are an expression?" {mixed plural and singular}
ThatGuyDuncan (68) [Avatar] Offline
#43
7.3   Making life better through Expressions
"We’ve now split our code into two methods – one which has the single responsibility of generating the description, and the other that uses that calls it and uses the result later on."
ThatGuyDuncan (68) [Avatar] Offline
#44
7.6   Introducing Unit
"Let’s look {at?} some functions and methods from both the code above and the BCL."
ThatGuyDuncan (68) [Avatar] Offline
#45
7.9   Forcing statement-based evaluation
Cryptic compiler errors
One of the elements of F# 4 that I’m not especially fond of are the error messages that it spits out, which are a throwback to F#’s OCaml roots. {mixing singular & plural}

For example, if you create an if / else expression that returns a string value for the if branch, but forget to handle an else branche, you’ll see an error similar to this:
ThatGuyDuncan (68) [Avatar] Offline
#46
7.10   Summary
In this lesson: - {extraneous hyphen}

You saw how expressions in F# are a fundamental feature of the language, whereas statements are shied away from – leading us down the road of writing code in a manner that is less likely to lead to bugs.
ThatGuyDuncan (68) [Avatar] Offline
#47
9    Shaping data with Tuples
We’ll start this unit by looking at the simplest data structure in F#, the Tuple. In this lesson: -

·   You’ll see how Tuples are used within F#
·   You’ll understand when to use and not use it
·   You’ll see how tuples work together with type inference to enable succinct code
·   You’ll see how Tuples relate to the rest of .NET
ThatGuyDuncan (68) [Avatar] Offline
#48
9.1   Priming exercise – returning data from a method
The following method takes in a string {which?} contains an individuals name e.g. “Isaac Abraham” and splits it out into its constituent parts, returning both the forename and surname.

Very quickly you end up with many different DTOs, all of which are very similar – and probably have to map between them, as C# doesn’t support structural typing i.e. the ability to compare to objects that have the same structure rather than type name.

There’s actually work going {on?} in the C# team to try to improve this in the future for C#.
ThatGuyDuncan (68) [Avatar] Offline
#49
9.2.1   When should I use Tuples?
F# also have two built-in functions for working with two-part tuples – fst and snd.
ThatGuyDuncan (68) [Avatar] Offline
#50
9.5.1   Tuples and the BCL
One of the nicest parts of F# is for it handles interoperability between F# and C# / VB. There’s plenty to see on this later on in the book, but as an example, we’ll see now how F# uses tuple language support to elegantly remove the for out parameters.
ThatGuyDuncan (68) [Avatar] Offline
#51
9.5.2   When not to use Tuples
So, whilst tuples are very useful (as we’ll see, they can simplify complicated type signatures), you’ll still need to be think a little about e.g. naming functions that return tuples intelligently so that it’s obvious what the parts of the tuple represent.
ThatGuyDuncan (68) [Avatar] Offline
#52
10    Shaping data with Records
In the previous lesson, we looked a lightweight, simple data of packaging data pieces together with the Tuple.
...
·   You’ll learn how to affect changes to records whilst still retaining immutability
·   You’ll see some tips for when working with records.
ThatGuyDuncan (68) [Avatar] Offline
#53
10.1   Priming exercise – creating an immutable type in C#
Let’s start by continuing where we left off in lesson 8 by describing a situation where Tuples aren’t suitable for exposing data – for example, a public contract of some sort where we want explicit named fields, or somewhere that you need to expose more than just two or three properties.

{is that "lesson 9"?}
ThatGuyDuncan (68) [Avatar] Offline
#54
10.2   POCOs done right - Records in F#
Note that for multiline declarations, just like the rest of the language, you need to all fields start on the same column.
I suggest you allow Visual F# Power Tools {to?} take care of formatting for you...
ThatGuyDuncan (68) [Avatar] Offline
#55
10.3   Creating Records
Create records in F# is super easy
We’ll cover the most common answer in a later lesson (Discriminated Unions), but the main point is that the type system will not allow you to declare a silently populate only part of a record.