Professional F# 2.0ISBN: 978-0-470-52801-3
Paperback
432 pages
November 2010
This title is out-of-print and not currently available for purchase from this site.
|
FOREWORD xxi
INTRODUCTION xxiii
PART 0: BEGINNINGS
CHAPTER 1: PRIMER 3
Setup 5
It’s that Time of Year Again… 7
Strategy 10
The Delegate Strategy 12
Lambda Calculus (Briefly) 17
Type Inference 22
Immutability 26
Expressions, not Statements 27
Summary 28
PART I: BASICS
CHAPTER 2: LEXICAL STRUCTURE 31
Comments 31
Identifiers 32
Preprocessor Directives 33
Significant Whitespace 34
Summary 35
CHAPTER 3: PRIMITIVE TYPES 37
Boolean 37
Numeric Types 38
Bitwise Operations 40
Floating-Point Types 40
Arithmetic Conversions 41
String and Character Types 42
Unit 43
Units of Measure Types 43
Literal Values 44
Summary 45
CHAPTER 4: CONTROL FLOW 47
Basic Decisions: if 47
Looping: while/do 49
Looping: for 50
Exceptions 50
Summary 53
CHAPTER 5: COMPOSITE TYPES 55
Option Types 55
Tuples 58
Arrays 60
Lists 65
Using Lists and Arrays 72
Sequences 74
Maps 79
Sets 82
Summary 83
CHAPTER 6: PATTERN MATCHING 85
Basics 85
Pattern Types 88
Pattern Guards 94
Active Patterns 95
Summary 102
PART II: OBJECTS
CHAPTER 7: COMPLEX COMPOSITE TYPES 105
Type Abbreviations 105
Enum Types 106
Discriminated Union Types 109
Structs 114
Record Types 119
Summary 123
CHAPTER 8: CLASSES 125
Basics 125
Members 132
Static Members 146
Delegates and Events 149
Access Modifiers 155
Type Extensions 157
Summary 159
CHAPTER 9: INHERITANCE 161
Basics 161
Overriding 166
Casting 171
Interfaces 177
Object Expressions 181
Summary 181
CHAPTER 10: GENERICS 183
Basics 183
Type Constraints 186
Statically Resolved Type Parameters 189
Summary 190
CHAPTER 11: PACKAGING 191
Namespaces 191
Modules 193
Summary 195
CHAPTER 12: CUSTOM ATTRIBUTES 197
Using Custom Attributes 197
Creation and Consumption 203
CHAPTER 13: FUNCTIONS 209
Traditional Function Calls 209
Mathematical Functions 210
Coming from C# 211
Function Arguments and Return Values 211
Partial Application 215
Functions as First Class 218
Summary 223
CHAPTER 14: IMMUTABLE DATA 225
The Problem with State 225
State Safety 226
Data Mutation 232
Performance Considerations 239
Summary 245
CHAPTER 15: DATA TYPES 247
Ambiguously Typed Data 247
Failing Fast 248
Specificity 248
Summary 255
CHAPTER 16: LIST PROCESSING 257
Collection Abstractions 257
Module Functions 258
Collection Subsets 258
Element Transformations 260
Accumulators 263
Summary 267
CHAPTER 17: PIPELINING AND COMPOSITION 269
Basic Composition and Pipelining 269
Applying Pipelining and Composition 275
Summary 280
PART IV: APPLICATIONS
CHAPTER 18: C# 283
Overview 283
Calling C# Libraries from F# 284
Calling F# Libraries from C# 289
Rules of Thumb for Writing F# APIs 294
Summary 295
CHAPTER 19: DATABASES 297
Overview 297
Retrieving Data Using ADO.NET 298
F# and Object Relational Mapping 302
Introducing F# Active Record (FAR) 303
How FAR Works 306
Summary 315
CHAPTER 20: XML 317
Overview 317
F# and LINQ-to-XML 318
F# and XML DOM 325
F#, XML, and Active Patterns 329
Summary 339
CHAPTER 21: ASP.NET MVC 341
Overview 341
FORECAST’R The World’s Simplest Weather
Forecast Site 342
Summary 355
CHAPTER 22: SILVERLIGHT 357
Overview 357
Visual Studio Project Templates 360
The Silverlight Toolkit 365
Data Binding 368
Calculating Moving Average 372
Putting It All Together 373
Summary 376
CHAPTER 23: SERVICES 377
Overview 377
An F#-Based Weather Service 378
Leveraging the Domain Model 380
Writing the Service Controller 381
Consuming Services 385
Summary 390
INDEX 391