Get Programming with F#: A Guide for .NET Developers

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

F# is a mature, open-source functional-first language that's rapidly growing in popularity both inside and outside the .NET ecosystem. And while F# runs on the .NET framework and supports OO features, its functional nature is what's driving interest. F# leads to quicker development time and a lower total cost of ownership. Its powerful feature set allows developers to more succinctly express their intent, and encourages best practices - leading to higher quality deliverables in less time. Developers find working in F# more enjoyable and rewarding; their managers appreciate the improved quality and speed of deliverables!

Learn F# is a practical guide for experienced C# and .NET developers that teaches the F# language, tools, techniques, and practices that can be applied in common scenarios. You'll start with F# language basics and best development practices. You'll also learn the core set of FP techniques in F#, and why to use them. Then you'll discover how to write idiomatic F# code on the .NET framework in Visual Studio, and what tools to use to give you the best experience within VS. The second part of the book shows you how to apply F# in larger, real world scenarios, things like interop to C# /VB projects, SQL database access, web programming, and unit testing. By the end of the book, you'll be able to use F# in your day-to-day development, and know how and where to deepen your knowledge.

Author(s): Isaac Abraham
Publisher: Manning
Year: 2017

Language: English
Pages: 400

Get Programming with F#
Contents
Foreword
Preface
Acknowledgments
About this book
Who should read this book
How this book is organized
About the code
Book forum
About the author
Welcome to Get Programming with F#!
What is F#, and why does it matter?
F# and .NET
Summary
Unit 1 F# and Visual Studio
Lesson 1 The Visual Studio experience
1.1 Installing VS2015 with F#
1.2 Configuring Visual Studio for F#
1.3 Getting the best out of VS 2015 and F#
Summary
Lesson 2 Creating your first F# program
2.1 F# project types
2.2 Debugging applications in F#
2.3 Writing your first F# program
Summary
Lesson 3 The REPL—changing how we develop
3.1 Code-focused developer processes
3.2 Enter the REPL
3.3 F# scripts in Visual Studio
Summary
Unit 2 Hello F#
Lesson 4 Saying a little, doing a lot
4.1 Binding values in F#
4.2 Scoping values
Summary
Lesson 5 Trusting the compiler
5.1 Type inference as we know it
5.2 F# type-inference basics
5.3 Following the breadcrumbs
Summary
Lesson 6 Working with immutable data
6.1 Working with mutable data—a recap
6.2 Being explicit about mutation
6.3 Modeling state
Summary
Lesson 7 Expressions and statements
7.1 Comparing statements and expressions
7.2 Using expressions in F#
7.3 Forcing statement-based evaluation
Summary
Lesson 8 Capstone 1
8.1 Defining the problem
8.2 Some advice before you start
8.3 Starting small
8.4 Implementing core logic
8.5 Testing in scripts
8.6 Moving to a full application
Summary
Unit 3 Types and functions
Lesson 9 Shaping data with tuples
9.1 The need for tuples
9.2 Tuple basics
9.3 More-complex tuples
9.4 Tuple best practices
Summary
Lesson 10 Shaping data with records
10.1 POCOs done right: records in F#
10.2 Doing more with records
10.3 Tips and tricks with records
Summary
Lesson 11 Building composable functions
11.1 Partial function application
11.2 Constraining functions
11.3 Composing functions together
Summary
Lesson 12 Organizing code without classes
12.1 Using namespaces and modules
12.2 Moving from scripts to applications
12.3 Tips for working with modules and namespaces
Summary
Lesson 13 Achieving code reuse in F#
13.1 Reuse in the world of LINQ
13.2 Implementing higher-order functions in F#
13.3 Dependencies as functions
Summary
Lesson 14 Capstone 2
14.1 Defining the problem
14.2 Some advice before you start…
14.3 Getting started
14.4 Creating a domain
14.5 Creating behaviors
14.6 Abstraction and reuse through higher-order functions
14.7 Writing a console application
14.8 Referencing files from scripts
Summary
Unit 4 Collections in F#
Lesson 15 Working with collections in F#
15.1 F# collection basics
15.2 Collection types in F#
Summary
Lesson 16 Useful collection functions
16.1 Mapping functions
16.2 Grouping functions
16.3 More on collections
Summary
Lesson 17 Maps, dictionaries, and sets
17.1 Dictionaries
17.2 The F# Map
17.3 Sets
Summary
Lesson 18 Folding your way to success
18.1 Understanding aggregations and accumulators
18.2 Saying hello to fold
18.3 Composing functions with fold
Summary
Lesson 19 Capstone 3
19.1 Defining the problem
19.2 Removing mutability
19.3 Writing transactions to disk
19.4 Rehydrating an account from disk
Summary
Unit 5 The pit of success with the F# type system
Lesson 20 Program flow in F#
20.1 A tour around loops in F#
20.2 Branching logic in F#
20.3 Flexible pattern matching
20.4 To match or not to match
Summary
Lesson 21 Modeling relationships in F#
21.1 Composition in F#
21.2 Discriminated unions in F#
21.3 Tips for working with discriminated unions
21.4 More about discriminated unions
Summary
Lesson 22 Fixing the billion-dollar mistake
22.1 Working with missing values
22.2 Improving matters with the F# type system
22.3 Using the Option module
22.4 Collections and options
Summary
Lesson 23 Business rules as code
23.1 Specific types in F#
23.2 Encoding business rules with marker types
23.3 Results vs. exceptions
Summary
Lesson 24 Capstone 4
24.1 Defining the problem
24.2 Stronger typing with discriminated unions
24.3 Applying Option types with the outside world
24.4 Implementing business rules with types
Summary
Unit 6 Living on the .NET platform
Lesson 25 Consuming C# from F#
25.1 Referencing C# code in F#
25.2 The Visual Studio experience
25.3 Working with OO constructs
Summary
Lesson 26 Working with NuGet packages
26.1 Using NuGet with F#
26.2 Working with Paket
Summary
Lesson 27 Exposing F# types and functions to C#
27.1 Using F# types in C#
27.2 More on F# interoperability
27.3 Summarizing F# to C# interoperability
Summary
Lesson 28 Architecting hybrid language applications
28.1 Crossing language boundaries
28.2 Case study—WPF monopoly
Summary
Lesson 29 Capstone 5
29.1 Defining the problem
29.2 Plugging in a third-party NuGet package
29.3 Connecting F# code to a WPF front end
29.4 Common fields on discriminated unions
29.5 Polishing up F# APIs for consumers
29.6 Working with pure functions in a mutable world
Summary
Unit 7 Working with data
Lesson 30 Introducing type providers
30.1 Understanding type providers
30.2 Working with your first type provider
Summary
Lesson 31 Building schemas from live data
31.1 Working with JSON
31.2 Avoiding problems with live schemas
31.3 Mixing local and remote datasets
Summary
Lesson 32 Working with SQL
32.1 Creating a basic database
32.2 Introducing the SqlClient project
32.3 Using the SQLProvider
Summary
Lesson 33 Creating type provider-backed APIs
33.1 Creating a tightly coupled type provider API
33.2 Creating a decoupled API
Summary
Lesson 34 Using type providers in the real world
34.1 Securely accessing connection strings with type providers
34.2 Manually passing connection strings
34.3 Continuous integration with type providers
Summary
Lesson 35 Capstone 6
35.1 Defining the problem
35.2 Hooking up a SQL database
35.3 Creating a SQL data access layer
35.4 Making a pluggable data access layer
Summary
Unit 8 Web programming
Lesson 36 Asynchronous workflows
36.1 Comparing synchronous and asynchronous models
36.2 Introducing asynchronous workflows
36.3 Composing asynchronous values
36.4 Using fork/join
36.5 Using tasks and async workflows
Summary
Lesson 37 Exposing data over HTTP
37.1 Getting up and running with the ASP .NET Web API
37.2 Abstracting the Web API from F#
37.3 Working with Async
37.4 Introducing Suave
Summary
Lesson 38 Consuming HTTP data
38.1 Using FSharp.Data to work with HTTP endpoints
38.2 Working with HTTP.fs
38.3 Using the Swagger type provider
Summary
Lesson 39 Capstone 7
39.1 Defining the problem
39.2 Adding Web API support to your application
39.3 Consuming data with Swagger
39.4 Enriching the API
Summary
Unit 9 Unit testing
Lesson 40 Unit testing in F#
40.1 Knowing when to unit test in F#
40.2 Performing basic unit testing in F#
40.3 Testing DSLs in F#
Summary
Lesson 41 Property-based testing in F#
41.1 Understanding property-based testing
41.2 Introducing FsCheck
41.3 Controlling data generation
Summary
Lesson 42 Web testing
42.1 Web automation with Canopy
42.2 Web tests with Canopy
Summary
Lesson 43 Capstone 8
43.1 Defining the problem
43.2 Writing API tests
43.3 Testing the Web API tier
43.4 Using property-based tests
Summary
Unit 10 Where next?
Appendix A The F# community
A.1 The F# community
A.2 Coding in the open source world
A.3 A real-world example of open source contributions
Summary
Appendix B F# in my organization
B.1 Introducing F# to others
B.2 Introducing F# to your code base
Summary
Appendix C Must-visit F# resources
C.1 Websites
C.2 Social networks
C.3 Projects and language
Summary
Appendix D Must-have F# libraries
D.1 Libraries
D.2 The F# toolchain
Summary
Appendix E Other F# language features
E.1 Object-oriented support
E.2 Exception handling
E.3 Resource management
E.4 Casting
E.5 Active patterns
E.6 Computation expressions
E.7 Code quotations
E.8 Units of measure
E.9 Lazy computations
E.10 Recursion
Index
Symbols
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y