Muutke küpsiste eelistusi

Expert F# 2.0 1st ed. [Pehme köide]

  • Formaat: Paperback / softback, 624 pages, kõrgus x laius: 254x178 mm, kaal: 1162 g, XXVI, 624 p., 1 Paperback / softback
  • Ilmumisaeg: 01-Jun-2010
  • Kirjastus: APress
  • ISBN-10: 1430224312
  • ISBN-13: 9781430224310
  • Pehme köide
  • Hind: 53,33 €*
  • * hind on lõplik, st. muud allahindlused enam ei rakendu
  • Tavahind: 62,74 €
  • Säästad 15%
  • Raamatu kohalejõudmiseks kirjastusest kulub orienteeruvalt 2-4 nädalat
  • Kogus:
  • Lisa ostukorvi
  • Tasuta tarne
  • Tellimisaeg 2-4 nädalat
  • Lisa soovinimekirja
  • Formaat: Paperback / softback, 624 pages, kõrgus x laius: 254x178 mm, kaal: 1162 g, XXVI, 624 p., 1 Paperback / softback
  • Ilmumisaeg: 01-Jun-2010
  • Kirjastus: APress
  • ISBN-10: 1430224312
  • ISBN-13: 9781430224310
Functional programming is about concise, beautiful, and powerful code; and as you master the functional way of thinking you will get a boost in productivity and great personal enjoyment out of the clarity, compositionality, and brevity of your programs.

In this book, you'll learn about F# 2.0, an exciting young language that brings functional programming to .NET. F# 2.0 offers a unique combination of functional and object-oriented styles, has complete and seamless interoperability with .NET, and has many features and characteristics of dynamic languages but with the performance of a compiled language.

Expert F# 2.0 is the single most complete and comprehensive guide to the language, including all of its advanced features such as active patterns, sequence and computation expressions, quotations, units of measure, and lazy evaluation. Whether you're using standard functional features such as pattern matching and recursive functions or some unique F# features such as asynchronous workflows, it becomes natural to write programs that spawn threads, model probabilistic events, perform lightning-fast symbolic or numerical computations, translate and manipulate language representations, describe server and client code for web pages in a single entity, manipulate data using typed queries, draw custom UI controls, and interoperate with components built on unmanaged code, to name only a few. All of these and more are demonstrated by example in this book. Many of the examples are only a few lines long, and all are crafted with care, ready for use in your applications.

For functional programmers, this book is full of treasures and a whole host of practical guidance. If this is your first time with a functional language, look no further---you are in for a treat and a great journey! We wish you bon voyage and lots of fun on your exploration of this language.
Contents at a Glance iv
Foreword xxi
About the Author xxiii
About the Technical Reviewer xxiv
Acknowledgments xv
Chapter 1 Introduction
1(6)
The Genesis of F#
1(1)
About This Book
2(3)
Who This Book is For
5(2)
Chapter 2 Getting Started with F# and .NET
7(18)
Creating Your First F# Program
7(12)
Documenting Code Using XMLDocs
9(1)
Using let
9(1)
Understanding Types
10(1)
Calling Functions
11(1)
Lightweight Syntax
12(1)
Understanding Scope
13(1)
Using Data Structures
14(1)
Using Properties and the Dot-Notation
15(1)
Using Tuples
16(2)
Using Imperative Code
18(1)
Using .NET Libraries from F#
19(5)
Using open to Access Namespaces and Modules
20(1)
Using new and Setting Properties
21(1)
Fetching a Web Page
22(2)
Summary
24(1)
Chapter 3 Creating Your First F# Prog---Introducing Functional Programming
25(42)
Getting Started with F# Arithmetic
25(5)
Basic Literals
25(1)
Arithmetic Operators
26(1)
Bitwise Operations
27(1)
Arithmetic Conversions
28(1)
Arithmetic Comparisons
29(1)
Overloaded Math Functions
29(1)
Introducing Simple Strings
30(3)
Working with String Literals and Primitives
30(2)
Building Strings
32(1)
Working with Lists and Options
33(5)
Using F# Lists
33(4)
Using F# Option Values
37(1)
Using Option Values for Control
38(1)
Working with Conditionals: && and II
38(1)
Defining Recursive Functions
39(1)
Introducing Function Values
40(10)
Using Anonymous Function Values
41(1)
Computing with Aggregate Operators
42(2)
Composing Functions with >>
44(1)
Building Functions with Partial Application
45(1)
Using Local Functions
46(1)
Using Functions as Abstract Values
47(1)
Iterating with Aggregate Operators
48(1)
Abstracting Control with Functions
48(1)
Using .NET Methods as First-Class Functions
49(1)
Getting Started with Pattern Matching
50(3)
Matching on Structured Values
51(2)
Guarding Rules and Combining Patterns
53(1)
Getting Started with Sequences
53(5)
Using Range Expressions
54(1)
Iterating a Sequence
55(1)
Transforming Sequences with Aggregate Operators
55(1)
Which Types Can Be Used as Sequences?
56(1)
Using Lazy Sequences from External Sources
57(1)
Using Sequence Expressions
58(2)
Creating Sequence Expressions Using for
58(1)
Enriching Sequence Expressions with Additional Logic
59(1)
Generating Lists and Arrays Using Sequence Expressions
60(1)
Exploring Some Simple Type Definitions
60(6)
Defining Type Abbreviations
60(1)
Defining Records
61(1)
Handling Non-Unique Record Field Names
62(1)
Cloning Records
63(1)
Defining Discriminated Unions
63(2)
Using Discriminated Unions as Records
65(1)
Defining Multiple Types Simultaneously
66(1)
Summary
66(1)
Chapter 4 Introducing Imperative Programming
67(30)
Imperative Looping and Interating
68(1)
Simple for Loops
68(1)
Simple while Loops
68(1)
More Iteration Loops over Sequences
69(1)
Using Mutable Records
69(5)
Mutable Reference Cells
70(2)
Avoiding Aliasing
72(1)
Hiding Mutable Data
73(1)
Using Mutable Locals
74(1)
Working with Arrays
74(3)
Generating and Slicing Arrays
76(1)
Two-Dimensional Arrays
77(1)
Introducing the Imperative .NET Collections
77(4)
Using Resizeable Arrays
78(1)
Using Dictionaries
79(1)
Using Dictionary's TryGetValue
79(1)
Using Dictionaries with Compound Keys
80(1)
Some Other Mutable Data Structures
81(1)
Exceptions and Controlling Them
81(4)
Catching Exceptions
83(1)
Using try... finally
83(1)
Defining New Exception Types
84(1)
Having an Effect: Basic I/O
85(6)
Very Simple I/O: Reading and Writing Files
85(1)
.NET I/O via Streams
86(1)
Some Other I/O-Related Types
87(1)
Using System.Console
88(1)
Using printf and Friends
88(2)
Generic Structural Formatting
90(1)
Cleaning Up with IDisposable, use, and using
90(1)
Working with null Values
91(1)
Some Advice: Functional Programming with Side Effects
92(4)
Consider Replacing Mutable Locals and Loops with Recursion
93(1)
Separate Pure Computation from Side-Effecting Computations
93(1)
Separate Mutable Data Structures
93(1)
Not All Side Effects Are Equal
94(1)
Avoid Combining Imperative Programming and Laziness
95(1)
Summary
96(1)
Chapter 5 Mastering Types and Generics
97(26)
Understanding Generic Type Variables
97(1)
Writing Generic Functions
98(1)
Understanding Some Important Generic Functions
99(5)
Generic Comparison
99(1)
Generic Hashing
100(1)
Generic Pretty-Printing
101(1)
Generic Boxing and Unboxing
101(1)
Generic Binary Serialization via the .NET Libraries
102(2)
Making Things Generic
104(5)
Generic Algorithms through Explicit Arguments
104(2)
Generic Algorithms through Abstract Object Types
106(2)
Arithmetic Operators and Generic Algorithms through Inlining
108(1)
Understanding .NET Types
109(2)
Reference Types and Value Types
109(1)
Other Flavors of .NET Types
110(1)
Understanding Subtyping
111(4)
Casting Up Statically
111(1)
Casting Down Dynamically
111(1)
Performing Type Tests via Pattern Matching
112(1)
Knowing When Upcasts Are Applied Automatically
113(1)
Flexible Types
114(1)
Units of Measure
115(2)
Troubleshooting Type-Inference Problems
117(5)
Using a Visual Editing Environment
117(1)
Using Type Annotations
117(1)
Understanding the Value Restriction
118(1)
Working Around the Value Restriction
119(2)
Understanding Generic Overloaded Operators
121(1)
Summary
122(1)
Chapter 6 Working with Objects and Modules
123(30)
Getting Started with Objects and Members
123(3)
Using Classes
126(4)
Adding Further Object Notation to Your Types
130(5)
Working with Indexer Properties
130(1)
Adding Overloaded Operators
130(2)
Using Named and Optional Arguments
132(1)
Using Optional Property Settings
133(1)
Adding Method Overloading
134(1)
Defining Object Types with Mutable State
135(2)
Getting Started with Object Interface Types
137(6)
Defining New Object Interface Types
138(1)
Implementing Object Interface Types Using Object Expressions
139(1)
Implementing Object Interface Types Using Concrete Types
140(1)
Using Common Object Interface Types from the .NET Libraries
141(1)
Understanding Hierarchies of Object Interface Types
142(1)
More Techniques to Implement Objects
143(4)
Combining Object Expressions and Function Parameters
143(1)
Defining Partially Implemented Class Types
144(1)
Using Partially Implemented Types via Delegation
145(1)
Using Partially Implemented Types via Implementation Inheritance
145(2)
Using Modules and Static Members
147(1)
Extending Existing Types and Modules
148(2)
Working with F# Objects and .NET Types
150(2)
Structs
151(1)
Delegates
151(1)
Enums
151(1)
Summary
152(1)
Chapter 7 Encapsulating and Packaging Your Code
153(22)
Hiding Things Away
153(6)
Hiding Things with Local Definitions
154(2)
Hiding Things with Accessibility Annotations
156(3)
Using Namespaces and Modules
159(2)
Putting Your Code in a Namespace
159(1)
Using Files as Modules
160(1)
Creating Assemblies, DLLs, and EXEs
161(6)
Compiling EXEs
161(1)
Compiling DLLs
161(2)
Mixing Scripting and Compiled Code
163(1)
Choosing Optimization Settings
164(1)
Generating Documentation
164(1)
Building Shared Libraries and Using the Global Assembly Cache
165(1)
Using Static Linking
166(1)
Using Signature Types and Files
167(2)
Using Explicit Signature Types and Signature Files
167(1)
When Are Signature Types Checked?
168(1)
Packaging Applications
169(4)
Packaging Different Kinds of Code
169(1)
Using Data and Configuration Settings
170(3)
Summary
173(2)
Chapter 8 Mastering F#: Common Techniques
175(32)
Equality, Hashing, and Comparison
175(5)
Asserting Equality, Hashing, and Comparison Using Attributes
176(1)
Fully Customizing Equality, Hashing, and Comparison on a Type
177(2)
Suppressing Equality, Hashing, and Comparison on a Type
179(1)
Customizing Generic Collection Types
179(1)
Efficient Precomputation and Caching
180(6)
Precomputation and Partial Application
180(2)
Precomputation and Objects
182(1)
Memoizing Computations
183(2)
Lazy Values
185(1)
Other Variations on Caching and Memoization
186(1)
Cleaning Up Resources
186(8)
Cleaning Up with use
187(2)
Managing Resources with More Complex Lifetimes
189(1)
Cleaning Up Internal Objects
190(1)
Cleaning Up Unmanaged Objects
191(1)
Cleaning Up in Sequence Expressions
192(2)
Using using
194(1)
Stack as a Resource: Tail Calls and Recursion
194(8)
Tail Recursion and List Processing
195(2)
Tail Recursion and Object-Oriented Programming
197(1)
Tail Recursion and Processing Unbalanced Trees
198(1)
Using Continuations to Avoid Stack Overflows
199(2)
Another Example: Processing Syntax Trees
201(1)
Events
202(3)
Events as First-Class Values
203(1)
Creating and Publishing Events
204(1)
Summary
205(2)
Chapter 9 Introducing Language-Oriented Programming
207(42)
Using XML as a Concrete Language Format
208(5)
Using the System.Xml Namespace
208(2)
From Concrete XML to Abstract Syntax
210(3)
Working with Abstract Syntax Representations
213(7)
Abstract Syntax Representations: Less is More
213(1)
Processing Abstract Syntax Representations
213(2)
Transformational Traversals of Abstract Syntax Representations
215(1)
Using On-Demand Computation with Abstract Syntax Trees
215(2)
Caching Properties in Abstract Syntax Trees
217(1)
Memoizing Construction of Syntax Tree Nodes
218(2)
Introducing Active Patterns
220(5)
Converting the Same Data to Many Views
220(2)
Matching on .NET Object Types
222(1)
Defining Partial and Parameterized Active Patterns
223(1)
Hiding Abstract Syntax Implementations with Active Patterns
223(2)
Embedded Computational Languages with Workflows
225(14)
An Example: Success/Failure Workflows
227(3)
Defining a Workflow Builder
230(2)
Workflows and Untamed Side Effects
232(1)
Example: Probabilistic Workflows
233(5)
Combining Workflows and Resources
238(1)
Recursive Workflow Expressions
238(1)
Using F# Reflection
239(5)
Reflecting on Types
239(1)
Schema Compilation by Reflecting on Types
239(4)
Using the F# Dynamic Reflection Operators
243(1)
Using F# Quotations
244(4)
Example: Using F# Quotations for Error Estimation
245(2)
Resolving Top Definitions
247(1)
Summary
248(1)
Chapter 10 Using the F# and .NET Libraries
249(22)
A High-Level Overview
249(4)
Namespaces from the .NET Framework
250(2)
Namespaces from the F# Libraries
252(1)
Using the System Types
253(2)
Using Regular Expressions and Formatting
255(7)
Matching with System. Text. RegularExpressions
255(5)
Formatting Strings Using .NET Formatting
260(1)
Encoding and Decoding Unicode Strings
261(1)
Encoding and Decoding Binary Data
262(1)
Using Further F# and .NET Data Structures
262(1)
System.Collections.Generic and Other .NET Collections
262(1)
Introducing Microsoft.FSharp.Math
263(2)
Using Matrices and Vectors
263(2)
Using Operator Overloads on Matrices and Vectors
265(1)
Supervising and Isolating Execution
265(1)
Further Libraries for Reflective Techniques
266(1)
Using General Types
266(1)
Using Microsoft.FSharp.Reflection
267(1)
Some Other .NET Types You May Encounter
267(1)
Some Other .NET Libraries
268(1)
Summary
269(2)
Chapter 11 Building Graphical User Interfaces
271(50)
Writing "Hello, World!" in a Click
271(1)
Understanding the Anatomy of a Graphical Application
272(1)
Composing User Interfaces
273(5)
Drawing Applications
278(4)
Writing Your Own Controls
282(4)
Developing a Custom Control
282(3)
Anatomy of a Control
285(1)
Displaying Samples from Sensors
286(12)
Building the GraphControl: The Model
288(2)
Building the GraphControl: Style Properties and Controller
290(3)
Building the GraphControl: The View
293(4)
Putting It Together
297(1)
Creating a Mandelbrot Viewer
298(11)
Computing Mandelbrot
299(1)
Setting Colors
300(3)
Creating the Visualization Application
303(2)
Creating the Application Plumbing
305(4)
Windows Presentation Foundation
309(11)
When GUIs Meet the Web
311(1)
Drawing
312(3)
Controls
315(3)
Bitmaps and Images
318(2)
Final Considerations
320(1)
Summary
320(1)
Chapter 12 Working with Symbolic Representations
321(34)
Symbolic Differentiation and Expression Rendering
322(18)
Modeling Simple Algebraic Expressions
322(2)
Implementing Local Simplifications
324(1)
A Richer Language of Algebraic Expressions
325(2)
Parsing Algebraic Expressions
327(2)
Simplifying Algebraic Expressions
329(2)
Symbolic Differentiation of Algebraic Expressions
331(1)
Rendering Expressions
332(6)
Building the User Interface
338(2)
Verifying Circuits with Propositional Logic
340(14)
Representing Propositional Logic
341(1)
Evaluating Propositional Logic Naively
342(2)
From Circuits to Propositional Logic
344(3)
Checking Simple Properties of Circuits
347(1)
Representing Propositional Formulae Efficiently Using BDDs
348(4)
Circuit Verification with BDDs
352(2)
Summary
354(1)
Chapter 13 Reactive, Asynchronous, and Parallel Programming
355(36)
Introducing Some Terminology
356(1)
Using and Designing Background Workers
357(8)
Building a Simpler Iterative Worker
359(3)
Raising Additional Events from Background Workers
362(1)
Connecting a Background Worker to a GUI
363(2)
Introducing Asynchronous and Parallel Computations
365(12)
Fetching Multiple Web Pages in Parallel, Asynchronously
365(2)
Understanding Thread Hopping
367(1)
Under the Hood: What Are Asynchronous Computations?
368(2)
Parallel File Processing Using Asynchronous Workflows
370(4)
Running Asynchronous Computations
374(1)
Common I/O Operations in Asynchronous Workflows
374(1)
Under the Hood: Implementing Async. Parallel
375(1)
Using async for CPU Parallelism with Fixed Tasks
376(1)
Understanding Exceptions and Cancellation
376(1)
Passing and Processing Messages
377(8)
Introducing Message Processing
378(1)
Creating Objects That React to Messages
379(3)
Scanning Mailboxes for Relevant Messages
382(1)
Example: Asynchronous Web Crawling
383(2)
Using Shared-Memory Concurrency
385(4)
Creating Threads Explicitly
386(1)
Shared Memory, Race Conditions, and the .NET Memory Model
386(1)
Using Locks to Avoid Race Conditions
387(1)
Using ReaderWriterLock
388(1)
Some Other Concurrency Primitives
389(1)
Summary
389(2)
Chapter 14 Building Smart Web Applications
391(44)
Serving Static Web Content
391(4)
Serving Dynamic Web Content with ASP.NET
395(10)
Understanding the Languages Used in ASP.NET
397(2)
A Simple ASP.NET Web Application
399(3)
Deploying and Running the Application
402(2)
Using Code-Behind Files
404(1)
Using ASP.NET Input Controls
405(3)
Displaying Data from Databases
408(4)
Going Further with ASP.NET
412(10)
ASP.NET Directives
412(1)
Server Controls
413(2)
Debugging, Profiling, and Tracing
415(1)
Understanding the ASP.NET Event Model
416(2)
Maintaining the View State
418(1)
Understanding the Provider Model
419(1)
Creating Custom ASP.NET Server Controls
420(2)
Building Ajax Rich Client Applications
422(8)
More on the WebSharper Platform
422(8)
Using WSDL Web Services
430(4)
Consuming Web Services
430(3)
Calling Web Services Asynchronously
433(1)
Summary
434(1)
Chapter 15 Working with Data
435(28)
Querying In-Memory Data Structures
435(4)
Select/Where/From Queries Using Aggregate Operators
436(1)
Using Aggregate Operators in Queries
436(1)
Accumulating Using Folding Operators
437(1)
Expressing Some Queries Using Sequence Expressions
438(1)
Using Databases to Manage Data
439(13)
Choosing Your Database Engine
441(1)
Understanding ADO.NET
442(1)
Establishing Connections to a Database Engine
443(1)
Creating a Database
443(2)
Creating Tables and Inserting and Fetching Records
445(2)
Using Untyped Datasets
447(2)
Generating Typed Datasets Using xsd.exe
449(2)
Using Stored Procedures
451(1)
Using Data Grids
452(1)
Working with Databases in Visual Studio
452(3)
Creating a Database
452(1)
Visual Data Modeling: Adding Relationships
453(2)
Accessing Relational Data with Linq Queries
455(3)
Generating the Object/Relational Mapping
455(1)
Building the DataContext Instance
456(1)
Using LINQ from F#
456(2)
Working with XML as a Generic Data Format
458(3)
Constructing XML via LINQ
459(1)
Storing, Loading, and Traversing LinqToXml Documents
460(1)
Querying XML
461(1)
Summary
461(2)
Chapter 16 Lexing and Parsing
463(28)
Processing Line-Based Input
464(2)
On-Demand Reading of Files
465(1)
Using Regular Expressions
465(1)
Tokenizing with FsLex
466(8)
The FsLex Input in More Detail
469(1)
Generating a Simple Token Stream
470(2)
Tracking Position Information Correctly
472(1)
Handling Comments and Strings
473(1)
Recursive-Descent Parsing
474(5)
Limitations of Recursive-Descent Parsers
478(1)
Parsing with FsYacc
479(7)
The Lexer for Kitty
480(1)
The Parser for Kitty
481(2)
Parsing Lists
483(1)
Resolving Conflicts, Operator Precedence, and Associativity
483(1)
Putting It Together
484(2)
Binary Parsing and Pickling Using Combinators
486(3)
Summary
489(2)
Chapter 17 Interoperating with C and COM
491(32)
Common Language Runtime
491(2)
Memory Management at Runtime
493(2)
COM Interoperability
495(12)
Platform Invoke
507(14)
Getting Started with PInvoke
509(1)
Data Structures
510(3)
Marshalling Strings
513(3)
Function Pointers
516(1)
PInvoke Memory Mapping
517(3)
Wrapper Generation and Limits of PInvoke
520(1)
Summary
521(2)
Chapter 18 Debugging and Testing F# Programs
523(22)
Debugging F# Programs
524(9)
Using Advanced Features of the Visual Studio Debugger
526(2)
Instrumenting Your Program with the System. Diagnostics Namespace
528(3)
Debugging Concurrent and Graphical Applications
531(2)
Debugging and Testing with F# Interactive
533(5)
Controlling F# Interactive
534(1)
Some Common F# Interactive Directives
535(1)
Understanding How F# Interactive Compiles Code
535(2)
F# Interactive and Visual Studio
537(1)
Unit Testing
538(5)
Summary
543(2)
Chapter 19 Designing F# Libraries
545(18)
Designing Vanilla .NET Libraries
546(4)
Understanding Functional Design Methodology
550(3)
Applying the .NET Library Design Guidelines to F#
553(7)
Some Recommended Coding Idioms
560(1)
Summary
561(2)
Appendix F Brief Language Guide 563(8)
Index 571
strongDon Syme/strong is a principal researcher at Microsoft Research, and the main designer of F#. Since joining Microsoft Research in 1998, he has been a seminal contributor to a wide variety of leading-edge projects, including generics in C# and the .NET Common Language Runtime, F# itself, F# asynchronous programming and units of measure in F#. He received a Ph.D. from the University of Cambridge Computer Laboratory in 1999.