Muutke küpsiste eelistusi

Expert F# 1st ed. [Kõva köide]

  • Formaat: Hardback, 609 pages, kõrgus x laius: 235x178 mm, kaal: 1403 g, 6 Illustrations, color; 97 Illustrations, black and white; XXVII, 609 p. 103 illus., 6 illus. in color., 1 Hardback
  • Ilmumisaeg: 07-Dec-2007
  • Kirjastus: APress
  • ISBN-10: 1590598504
  • ISBN-13: 9781590598504
  • Kõva 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: Hardback, 609 pages, kõrgus x laius: 235x178 mm, kaal: 1403 g, 6 Illustrations, color; 97 Illustrations, black and white; XXVII, 609 p. 103 illus., 6 illus. in color., 1 Hardback
  • Ilmumisaeg: 07-Dec-2007
  • Kirjastus: APress
  • ISBN-10: 1590598504
  • ISBN-13: 9781590598504
Expert F# is about practical programming in a beautiful language that puts the power and elegance of functional programming into the hands of .NET developers. In combination with .NET, F# achieves unrivaled levels of programmer productivity and program clarity. This books serves as







The authoritative guide to F# by the designer of F# A comprehensive reference of F# concepts, syntax, and features A treasury of expert F# techniques for practical, realworld programming



While inspired by OCaml, F# isn't just another functional programming language. Drawing on many of the strengths of both OCaml and .NET, it's a generalpurpose language ideal for realworld development. F# integrates functional, imperative, and objectoriented programming styles so you can flexibly and elegantly solve programming problems, and brings .NET development alive with interactive execution. Whatever your background, you'll find that F# is easy to learn, fun to use, and extraordinarily powerful. F# will help change the way you think about and go about programming.



Written by F#'s designer and two active contributors, Expert F# is the authoritative, comprehensive, and indepth guide to the language and its use. Designed to help others become experts, the book gives a thorough introduction to the F# language from quick essentials to indepth advanced topics such as active pattern matching, aggregate data types and operators, sequence expressions, lazy values, mutable data and sideeffects, generics, type augmentations, functional decomposition and code organization.



The second half of the book is devoted to examining the practical application of F#, providing elegant solutions to common programming tasks including user interface implementation, data access, web and distributed programming, symbolic and numerical computations, concurrent programming, testing, profiling, andinteroperability with other languages. The latest hot developments in F# and .NET are also addressed, including Active Patterns, implicit class construction, integration with LINQ over relational data, meta programming and useful tips for working with Visual Studio and F# commandline tools.



The worlds foremost experts in F# show you how to program in F# the way they do!
Foreword xxi
About the Authors xxiii
About the Technical Reviewer xxv
Acknowledgments xxvii
Introduction
1(6)
The Genesis of F#
1(1)
About This Book
2(3)
Who This Book Is For
5(2)
Getting Started with F# and. NET
7(20)
Creating Your First F# Program
7(13)
Turning On the Lightweight Syntax Option
9(1)
Documenting Code Using XMLDocs
10(1)
Understanding Scope and Using ``let''
10(3)
Understanding Types
13(1)
Calling Functions
14(1)
Using Data Structures
15(1)
Using Properties and the Dot-Notation
16(1)
Using Tuples
17(2)
Using Imperative Code
19(1)
Using .NET Libraries from F#
20(5)
Using open to Access Namespaces and Modules
21(1)
Using new and Setting Properties
22(1)
Fetching a Web Page
23(2)
Summary
25(2)
Introducing Functional Programming
27(42)
Getting Started with F# Arithmetic
27(4)
Basic Literals
27(1)
Arithmetic Operators
28(1)
Bitwise Operations
29(1)
Arithmetic Conversions
30(1)
Arithmetic Comparisons
31(1)
Overloaded Math Functions
31(1)
Introducing Simple Strings
31(3)
Working with String Literals and Primitives
32(1)
Building Strings
33(1)
Working with Lists and Options
34(5)
Using F# Lists
34(3)
Using F# Option Values
37(2)
Using Option Values for Control
39(1)
Working with Conditionals: && and II
39(1)
Defining Recursive Functions
40(2)
Introducing Function Values
42(9)
Using Anonymous Function Values
43(1)
Computing with Aggregate Operators
44(1)
Composing Functions with >>
45(1)
Building Functions with Partial Application
46(1)
Using Local Functions
47(1)
Using Functions As Abstract Values
48(1)
Iterating with Aggregate Operators
49(1)
Abstracting Control with Functions
49(1)
Using .NET Methods As First-Class Functions
50(1)
Getting Started with Pattern Matching
51(4)
Matching on Structured Values
53(1)
Guarding Rules and Combining Patterns
54(1)
Getting Started with Sequences
55(4)
Using Range Expressions
55(1)
Iterating a Sequence
56(1)
Transforming Sequences with Aggregate Operators
56(1)
Which Types Can Be Used As Sequences?
57(1)
Using Lazy Sequences from External Sources
58(1)
Using Sequence Expressions
59(3)
Creating Sequence Expressions Using for
60(1)
Enriching Sequence Expressions with Additional Clauses
60(1)
Enriching Sequence Expressions to Specify Lists and Arrays
61(1)
Exploring Some Simple Type Definitions
62(6)
Defining Type Abbreviations
62(1)
Defining Records
63(1)
Handling Non-unique Record Field Names
64(1)
Cloning Records
64(1)
Defining Discriminated Unions
65(2)
Using Discriminated Unions As Records
67(1)
Defining Multiple Types Simultaneously
67(1)
Summary
68(1)
Introducing Imperative Programming
69(32)
Imperative Looping and Iterating
70(2)
Simple for loops
70(1)
Simple while loops
71(1)
More Iteration Loops Over Sequences
71(1)
Using Mutable Records
72(4)
Mutable Reference Cells
73(1)
Avoiding Aliasing
74(1)
Hiding Mutable Data
75(1)
Using Mutable Locals
76(1)
Working with Arrays
77(3)
Generating and Slicing Arrays
79(1)
Two-Dimensional Arrays
80(1)
Introducing the Imperative .NET Collections
80(4)
Using Resizeable Arrays
80(1)
Using Dictionaries
81(1)
Using Dictionary's TryGetValue
82(1)
Using Dictionaries with Compound Keys
83(1)
Some Other Mutable Data Structures
84(1)
Exceptions and Controlling Them
84(4)
Catching Exceptions
86(1)
Using try... finally
86(1)
Defining New Exception Types
87(1)
Having an Effect: Basic I/O
88(6)
Very Simple I/O: Reading and Writing Files
88(1)
.NET I/O via Streams
89(2)
Some Other I/O-Related Types
91(1)
Using System.Console
91(1)
Using printf and Friends
91(2)
Generic Structural Formatting
93(1)
Cleaning Up with IDisposable, use, and using
93(1)
Working with null Values
94(1)
Some Advice: Functional Programming with Side Effects
95(5)
Consider Replacing Mutable Locals and Loops with Recursion
96(1)
Separate Pure Computation from Side-Effecting Computations
96(1)
Separating Mutable Data Structures
97(1)
Not All Side Effects Are Equal
98(1)
Avoid Combining Imperative Programming and Laziness
98(2)
Summary
100(1)
Mastering Types and Generics
101(24)
Understanding Generic Type Variables
101(1)
Writing Generic Functions
102(1)
Understanding Some Important Generic Functions
103(5)
Generic Comparison
103(2)
Generic Hashing
105(1)
Generic Pretty-Printing
105(1)
Generic Boxing and Unboxing
106(1)
Generic Binary Serialization via the .NET Libraries
107(1)
Making Things Generic
108(4)
Generic Algorithms Through Explicit Arguments
108(2)
Generic Algorithms Through Abstract Object Types
110(2)
Understanding .NET Types
112(1)
Reference Types and Value Types
112(1)
Other Flavors of .NET Types
113(1)
Understanding Subtyping
113(5)
Casting Up Statically
114(1)
Casting Down Dynamically
114(1)
Performing Type Tests via Pattern Matching
115(1)
Using Flexible # Types
116(1)
Knowing When Upcasts Are Applied Automatically
117(1)
Troubleshooting Type Inference Problems
118(5)
Using a Visual Editing Environment
118(1)
Using Type Annotations
118(1)
Understanding the Value Restriction
119(1)
Working Around the Value Restriction
120(3)
Understanding Generic Overloaded Operators
123(1)
Summary
123(2)
Working with Objects and Modules
125(30)
Getting Started with Objects and Members
125(3)
Using Constructed Classes
128(3)
Adding Further Object Notation to Your Types
131(6)
Working with Indexer Properties
131(1)
Adding Overloaded Operators
132(1)
Using Named and Optional Arguments
133(1)
Using Optional Property Settings
134(1)
Adding Method Overloading
135(2)
Defining Object Types with Mutable State
137(2)
Getting Started with Object Interface Types
139(5)
Defining New Object Interface Types
140(1)
Implementing Object Interface Types Using Object Expressions
140(2)
Implementing Object Interface Types Using Concrete Types
142(1)
Using Common Object Interface Types from the .NET Libraries
142(1)
Understanding Hierarchies of Object Interface Types
143(1)
More Techniques to Implement Objects
144(4)
Combining Object Expressions and Function Parameters
144(2)
Defining Partially Implemented Class Types
146(1)
Using Partially Implemented Types via Delegation
146(1)
Using Partially Implemented Types via Implementation Inheritance
147(1)
Using Modules and Static Members
148(2)
Extending Existing Types and Modules
150(1)
Working with F# Objects and .NET Types
151(2)
Structs
152(1)
Delegates
152(1)
Enums
153(1)
Summary
153(2)
Encapsulating and Packaging Your Code
155(26)
Hiding Things Away
156(5)
Hiding Things with Local Definitions
156(2)
Hiding Things with Accessibility Annotations
158(3)
Using Namespaces and Modules
161(3)
Putting Your Code in a Namespace
162(1)
Using Files As Modules
163(1)
Using Signature Types and Files
164(2)
Using Explicit Signature Types and Signature Files
164(2)
When Are Signature Types Checked?
166(1)
Creating Assemblies, DLLs, and EXEs
166(7)
Compiling EXEs
166(1)
Compiling DLLs
167(1)
Mixing Scripting and Compiled Code
168(1)
Choosing Optimization Settings
169(1)
Generating Documentation
170(1)
Building Shared Libraries and the Using Global Assembly Cache
171(1)
Using Static Linking
172(1)
Packaging Applications
173(6)
Packaging Different Kinds of Code
173(1)
Using Data and Configuration Settings
174(3)
Building Installers
177(1)
Deploying Web Applications
178(1)
Summary
179(2)
Mastering F#: Common Techniques
181(30)
Equality, Hashing, and Comparison
181(3)
Efficient Precomputation and Caching
184(6)
Precomputation and Partial Application
184(1)
Precomputation and Objects
185(2)
Memoizing Computations
187(2)
Lazy Values
189(1)
Other Variations on Caching and Memoization
190(1)
Cleaning Up Resources
190(8)
Cleaning Up with use
191(2)
Managing Resources with More Complex Lifetimes
193(1)
Cleaning Up Internal Objects
194(2)
Cleaning Up Unmanaged Objects
196(1)
Cleaning Up in Sequence Expressions
197(1)
Using using
198(1)
Stack As a Resource: Tail Calls and Recursion
198(9)
Tail Recursion and List Processing
200(2)
Tail Recursion and Object-Oriented Programming
202(1)
Tail Recursion and Processing Unbalanced Trees
203(1)
Using Continuations to Avoid Stack Overflows
204(2)
Another Example: Processing Syntax Trees
206(1)
Events and Wiring
207(3)
Events As First-Class Values
208(1)
Creating and Publishing Events
209(1)
Summary
210(1)
Introducing Language-Oriented Programming
211(44)
Using XML As a Concrete Language Format
212(5)
Using the System.Xml Namespace
212(2)
From Concrete XML to Abstract Syntax
214(3)
Working with Abstract Syntax Representations
217(7)
Abstract Syntax Representations: ``Less Is More''
217(1)
Processing Abstract Syntax Representations
218(1)
Transformational Traversals of Abstract Syntax Representations
219(1)
Using On-Demand Computation with Abstract Syntax Trees
220(1)
Caching Properties in Abstract Syntax Trees
221(1)
Memoizing Construction of Syntax Tree Nodes
222(2)
Introducing Active Patterns
224(6)
Converting the Same Data to Many Views
225(2)
Matching on .NET Object Types
227(1)
Defining Partial and Parameterized Active Patterns
228(1)
Hiding Abstract Syntax Implementations with Active Patterns
228(2)
Embedded Computational Languages with Workflows
230(15)
An Example: Success/Failure Workflows
232(3)
Defining a Workflow Builder
235(3)
Workflows and ``Untamed'' Side Effects
238(1)
Example: Probabilistic Workflows
239(5)
Combining Workflows and Resources
244(1)
Recursive Workflow Expressions
244(1)
Using F# Reflection
245(4)
Reflecting on Types
245(1)
Schema Compilation by Reflecting on Types
245(4)
Using F# Quotations
249(5)
Example: Using F# Quotations for Error Estimation
251(2)
Resolving Top Definitions
253(1)
Summary
254(1)
Using the F# and .NET Libraries
255(20)
A High-Level Overview
255(4)
Namespaces from the .NET Framework
256(2)
Namespaces from the F# Libraries
258(1)
Using the System Types
259(2)
Using Regular Expressions and Formatting
261(5)
Matching with System.Text.RegularExpressions
261(4)
Formatting Strings Using .NET Formatting
265(1)
Encoding and Decoding Unicode Strings
266(1)
Encoding and Decoding Binary Data
266(1)
Using Further F# and .NET Data Structures
266(2)
System.Collections.Generic and Other .NET Collections
267(1)
Introducing Microsoft.FSharp.Math
268(2)
Using Matrices and Vectors
268(1)
Using Operator Overloads on Matrices and Vectors
269(1)
Supervising and Isolating Execution
270(1)
Further Libraries for Reflective Techniques
270(2)
Using General Types
270(1)
Using Microsoft.FSharp.Reflection
271(1)
Some Other .NET Types You May Encounter
272(1)
Some Other .NET Libraries
273(1)
Summary
274(1)
Working with Windows Forms and Controls
275(42)
Writing ``Hello, World!'' in a Click
275(1)
Understanding the Anatomy of a Graphical Application
276(1)
Composing User Interfaces
277(5)
Drawing Applications
282(5)
Writing Your Own Controls
287(4)
Developing a Custom Control
287(3)
Anatomy of a Control
290(1)
Displaying Samples from Sensors
291(12)
Building the GraphControl: The Model
292(2)
Building the GraphControl: Style Properties and Controller
294(4)
Building the GraphControl: The View
298(4)
Putting It Together
302(1)
Creating a Mandelbrot Viewer
303(12)
Computing Mandelbrot
304(1)
Setting Colors
305(3)
Creating the Visualization Application
308(2)
Creating the Application Plumbing
310(5)
Summary
315(2)
Working with Symbolic Representations
317(38)
Symbolic Differentiation and Expression Rendering
318(20)
Modeling Simple Algebraic Expressions
318(2)
Implementing Local Simplifications
320(1)
A Richer Language of Algebraic Expressions
321(2)
Parsing Algebraic Expressions
323(2)
Simplifying Algebraic Expressions
325(3)
Symbolic Differentiation of Algebraic Expressions
328(1)
Rendering Expressions
329(6)
Building the User Interface
335(3)
Verifying Circuits with Propositional Logic
338(15)
Representing Propositional Logic
339(1)
Evaluating Propositional Logic Naively
340(3)
From Circuits to Propositional Logic
343(3)
Checking Simple Properties of Circuits
346(1)
Representing Propositional Formulae Efficiently Using BDDs
347(3)
Circuit Verification with BDDs
350(3)
Summary
353(2)
Reactive, Asynchronous, and Concurrent Programming
355(38)
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 Computations
365(14)
Fetching Multiple Web Pages Asynchronously
365(2)
Understanding Thread Hopping
367(2)
Under the Hood: What Are Asynchronous Computations?
369(2)
File Processing Using Asynchronous Workflows
371(3)
Running Asynchronous Computations
374(1)
Common I/O Operations in Asynchronous Workflows
375(1)
Under the Hood: Implementing a Primitive Asynchronous Step
376(1)
Under the Hood: Implementing Async.Parallel
377(1)
Understanding Exceptions and Cancellation
378(1)
Passing and Processing Messages
379(9)
Introducing Message Processing
379(2)
Creating Objects That React to Messages
381(3)
Scanning Mailboxes for Relevant Messages
384(1)
Example: Asynchronous Web Crawling
385(3)
Using Shared-Memory Concurrency
388(4)
Creating Threads Explicitly
388(1)
Shared Memory, Race Conditions, and the .NET Memory Model
389(1)
Using Locks to Avoid Race Conditions
390(1)
Using ReaderWriterLock
391(1)
Some Other Concurrency Primitives
392(1)
Summary
392(1)
Building Web Applications
393(38)
Serving Static Web Content
393(3)
Serving Dynamic Web Content with ASP.NET
396(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(2)
Using ASP.NET Input Controls
406(3)
Displaying Data from Databases
409(3)
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(2)
Creating Custom ASP.NET Server Controls
421(1)
Building Ajax Rich Client Applications
422(2)
More on F# Web Tools
423(1)
Using Web Services
424(5)
Consuming Web Services
425(2)
Calling Web Services Asynchronously
427(2)
Summary
429(2)
Working with Data
431(30)
Querying In-Memory Data Structures
431(5)
Select/Where/From Queries Using Aggregate Operators
432(1)
Using Aggregate Operators in Queries
433(1)
Accumulating Using ``Folding'' Operators
434(1)
Expressing Some Queries Using Sequence Expressions
435(1)
Using Databases to Manage Data
436(14)
Choosing Your Database Engine
438(1)
Understanding ADO.NET
438(1)
Establishing Connections to a Database Engine
439(1)
Creating a Database
440(2)
Creating Tables, Inserting, and Fetching Records
442(2)
Using Untyped Datasets
444(2)
Generating Typed Datasets Using xsd.exe
446(2)
Using Stored Procedures
448(1)
Using Data Grids
449(1)
Working with Databases in Visual Studio
450(2)
Creating a Database
450(1)
Visual Data Modeling: Adding Relationships
450(2)
Accessing Relational Data with F# LinqToSql
452(3)
Generating the Object/Relational Mapping
453(1)
Building the DataContext Instance
453(1)
Using LinqToSql from F#
454(1)
Working with XML As a Generic Data Format
455(4)
Constructing XML via LINQ
457(1)
Storing, Loading, and Traversing LinqToXml Documents
458(1)
Querying XML
459(1)
Summary
459(2)
Lexing and Parsing
461(30)
Processing Line-Based Input
462(2)
On-Demand Reading of Files
463(1)
Using Regular Expressions
463(1)
Tokenizing with FsLex
464(9)
The fslex Input in More Detail
467(1)
Generating a Simple Token Stream
468(2)
Tracking Position Information Correctly
470(1)
Handling Comments and Strings
471(2)
Recursive-Descent Parsing
473(4)
Limitations of Recursive-Descent Parsers
477(1)
Parsing with FsYacc
477(9)
The Lexer for Kitty
478(2)
The Parser for Kitty
480(2)
Parsing Lists
482(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)
Interoperating with C and COM
491(32)
Common Language Runtime
491(3)
Memory Management at Run Time
494(2)
COM Interoperability
496(11)
Platform Invoke
507(15)
Getting Started with Plnvoke
508(2)
Data Structures
510(3)
Marshalling Strings
513(3)
Function Pointers
516(1)
Plnvoke Memory Mapping
517(3)
Wrapper Generation and Limits of Plnvoke
520(2)
Summary
522(1)
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(4)
Controlling F# Interactive
534(1)
Some Common F# Interactive Directives
535(1)
Understanding How F# Interactive Compiles Code
535(2)
Unit Testing
537(6)
Summary
543(2)
Designing F# Libraries
545(18)
Designing Vanilla .NET Libraries
546(5)
Understanding Functional Design Methodology
551(3)
Understanding Where Functional Programming Comes From
551(1)
Understanding Functional Design Methodology
552(2)
Applying the .NET Design Guidelines to F#
554(6)
Some Recommended Coding Idioms
560(2)
Summary
562(1)
APPENDIX F# Brief Language Guide
563(8)
Comments and Attributes
563(1)
Basic Types and Literals
563(1)
Types
564(1)
Patterns and Matching
564(1)
Functions, Composition, and Pipelining
564(1)
Binding and Control Flow
565(1)
Exceptions
565(1)
Tuples, Arrays, Lists, and Collections
566(1)
Operators
567(1)
Type Definitions and Objects
568(1)
Namespaces and Modules
569(1)
Sequence Expressions and Workflows
569(2)
Index 571


Antonio Cisternino is a professor in the Computer Science Department of the University of Pisa. His primary research is on scientific computing, meta-programming and domain-specific languages on virtual-machine-based execution environments. He has been active in the .NET community since 2001 and developed VSLab, a Microsoft Visual Studio add-in to support MATLAB-like programming in F# and Visual Studio. He is also author of annotated C#, an extension of C#, and Robotics4.NET, a framework for programming robots with Microsoft .NET. Cisternino holds a Ph.D. in Computer Science from the University of Pisa.