𝔖 Scriptorium
✦   LIBER   ✦

📁

F# in Action

✍ Scribed by Isaac Abraham


Publisher
Manning
Year
2024
Tongue
English
Leaves
587
Category
Library

⬇  Acquire This Volume

No coin nor oath required. For personal study only.

✦ Synopsis


F# is engineered to make functional programming practical and accessible. This book will get you started writing your first simple, robust, and high performing functional code.

F# lets you keep your code simple even in the most complex applications—and it’s the perfect language for taking your first steps in functional programming. This practical, example-driven guide shows you how to build professional applications the F# way.

In
F# in Action you will learn how to:

  • Write performant and robust systems with succinct F# code
  • Model domains quickly, easily and accurately with F#’s type system
  • Design solutions using functional programming patterns
  • Ingest and process disparate data sources
  • Develop data-driven web applications
  • Unit test F# code
  • Effectively model data using a variety of techniques
  • Use scripts to rapidly explore domains

F# in Action is based on author and Microsoft F# MVP Isaac Abraham’s years of experience working with developers as an F# consultant. It upgrades .NET development skills with the core principles of functional programming, and you’ll soon see how F#’s functional-first approach makes it easy to learn this powerful paradigm.

Forewords by Phillip Carter and Tomas Petricek.

Purchase of the print book includes a free eBook in PDF and ePub formats from Manning Publications.

About the technology

F# is a uniquely powerful programming language. Its “light touch” approach to functional programming helps you deliver error-free code without a lot of complex math and academic theory. Simply put, F# exists to help you write better software faster, and this book will show you how.

About the book

F# in Action teaches you to write professional quality applications in F#. For each concept, feature, and technique you’ll find hands-on examples, starting with simple data transformations and progressing all the way to a full-size web app. Throughout the book, you’ll take advantage of battle-tested .NET tools to take on a wide range of tasks—from data analysis to interoperability with C#.

What's inside

  • Model domains with F#’s type system
  • Ingest and process disparate data sources
  • Unit test F# code
  • Use scripts to rapidly explore domains


About the reader

For readers comfortable with any OO or FP language. Prior .NET knowledge not required!

About the author

Isaac Abraham is an experienced .NET developer, trainer, and Microsoft MVP for his contributions to the .NET community. Technical editor on this book was Michael Ciccotti.

Table of Contents

1 Introducing F#
2 Hands on with F#
3 F# Syntax Basics
4 F# Fundamentals
5 Shaping data
6 Functions and modules
7 Working with collections
8 Patterns and unions
9 Building rich domains
10 Working effectively with data
11 F# Interop
12 Asynchronous programming
13 Web programming
14 Testing F# code
15 Pure functional programming
16 Where next?

✦ Table of Contents


Praise for the previous edition
F# in Action
Copyright
contents
front matter
foreword
preface
acknowledgments
about this book
Who should read this book
How this book is organized: A road map
About the code
liveBook discussion forum
about the author
about the cover illustration
1 Introducing F#
1.1 What is F#?
1.2 Why F#?
1.3 When F#?
1.4 How will this book teach me F#?
1.5 How does F# work?
1.5.1 Collaborative exploration
1.5.2 Type-driven development
1.5.3 Trusting the compiler
1.5.4 An opinionated language
1.5.5 Data and functions
1.5.6 Separation of business logic and external systems
1.5.7 Varied targets
Summary
2 Hands on with F#
2.1 Writing code the F# way
2.1.1 What, not how
2.1.2 Composability
2.1.3 Data and behavior
2.1.4 Working with a smarter compiler
2.2 F# and .NET
2.3 Creating your first F# program
2.3.1 Installing F#
2.3.2 The .NET CLI
2.3.3 Hello World in F#
2.4 Getting Started with Visual Studio Code
2.4.1 The Ionide extension
2.4.2 Exploring F# with VS Code
2.4.3 Writing your first F#
2.5 REPL and scripts
2.5.1 The F# REPL
2.5.2 Trying out FSI
2.5.3 Moving to interactive scripts
2.5.4 State in the REPL
2.5.5 Creating your first function
2.6 Development flows
2.7 Where scripts and the REPL fit in
Summary
3 F# Syntax Basics
3.1 F# syntax basics
3.1.1 Characteristics of F# syntax
3.1.2 The let keyword
3.1.3 Scoping
3.2 Type inference
3.2.1 Benefits of type inference
3.2.2 Type inference basics
3.2.3 Inferring generics
3.2.4 Diagnosing unexpected type inference behavior
3.2.5 Limitations of type inference
3.2.6 Criticisms of type inference
3.3 Exercise answers
Summary
4 F# Fundamentals
4.1 Expressions
4.1.1 Purity and side effects
4.1.2 Difficulties with statements
4.1.3 Expressions to the rescue
4.1.4 Expressions in F#
4.1.5 Composability
4.1.6 Unit
4.1.7 Ignore
4.2 Immutable data
4.2.1 The problem with mutability
4.2.2 Modeling with mutable and immutable data
4.2.3 Optimizing and opinionated languages
4.2.4 Other benefits of immutable data
4.3 Exercise Answers
Summary
5 Shaping data
5.1 Composing types in F#
5.1.1 Data and functions in F#
5.2 Tuples
5.2.1 Tuple basics
5.2.2 More on tuples
5.2.3 Costs and benefits of tuples
5.3 Records
5.3.1 Defining, creating, and consuming records
5.3.2 More on records
5.3.3 Records and .NET
5.4 Anonymous records
5.4.1 Anonymous record tricks
5.5 Tuples or records
5.6 Exercise answers
Summary
6 Functions and modules
6.1 Functions
6.1.1 The truth behind F# functions
6.1.2 Partially applying functions
6.1.3 Pipelines
6.1.4 Using records and tuples with functions
6.1.5 Tupled functions
6.1.6 Comparing functions and methods
6.2 Organizing code
6.2.1 Namespaces
6.2.2 Modules
6.2.3 Moving from script to application: A step-by-step exercise
6.2.4 Referencing programs from scripts
6.2.5 Best practices for modules and namespaces
6.2.6 Tips and tricks
6.3 Answers to exercises
Summary
7 Working with collections
7.1 Higher-order functions
7.2 Functional collection pipelines
7.2.1 Imperative and declarative pipelines
7.2.2 Debugging pipelines
7.2.3 Understanding the List module
7.2.4 Common List functions
7.2.5 Ranges, slices, and indexing
7.3 Other collection types
7.3.1 Arrays
7.3.2 Sequences
7.3.3 ResizeArray
7.3.4 Dictionary
7.3.5 Map
7.3.6 Set
7.3.7 More on Sequences
7.3.8 Comprehensions
7.3.9 Comparing the different collection types
7.4 Aggregations
7.4.1 Imperative loops
7.4.2 Functional folds
7.4.3 Simulating Sequences
7.5 Answers to exercises
Summary
8 Patterns and unions
8.1 Introducing pattern matching
8.1.1 Exhaustive matching
8.1.2 Tuple matching
8.1.3 Simplifying pattern matches: A worked example
8.1.4 Record matching
8.1.5 Type inference
8.1.6 When guards
8.2 More advanced pattern matching
8.2.1 Recursive matching
8.2.2 Nested or conditions
8.2.3 Binding symbols
8.2.4 Collection matching
8.2.5 Match vs. if/then
8.3 Discriminated unions
8.3.1 Basics of discriminated unions
8.3.2 Pattern matching
8.3.3 Exhaustive matching with discriminated unions
8.3.4 Nested types with discriminated unions
8.3.5 Single-case discriminated unions
8.4 The F# type system
8.4.1 ANDing types
8.4.2 ORing types
8.4.3 ANDing values
Summary
9 Building rich domains
9.1 Working with missing values
9.1.1 The billion-dollar mistake: Working with nulls
9.1.2 Options are the answer
9.1.3 Option.map
9.1.4 Option.bind
9.1.5 Interop with .NET
9.1.6 Options and collections
9.2 Handling errors
9.2.1 Results
9.2.2 Handling multiple errors
9.2.3 Strongly typed errors
9.2.4 Exceptions
9.2.5 When to safely leave options and results
9.2.6 When to use options, results, and exceptions
9.3 Computation expressions
9.4 Domain modeling: A worked example
Summary
10 Working effectively with data
10.1 Best practices
10.1.1 Data is data
10.1.2 Separation of data and functionality
10.1.3 Don’t treat scripts as programs
10.1.4 Working with lists of results
10.2 Serialization of data
10.2.1 Deserializing JSON to F#
10.2.2 Acceptable alternatives to DTOs
10.2.3 Serializing F# into JSON
10.3 Type providers
10.3.1 Working with the JSON type provider
10.3.2 Working with external data sources
10.3.3 More data types from FSharp.Data
10.3.4 Best practices for type providers
10.4 Data visualization
10.5 Working with other data sources
10.5.1 The CLIMutable attribute
10.5.2 Working with SQL
10.6 Tooling options
Summary
11 F# Interop
11.1 Working with other .NET code
11.1.1 Consuming C# classes
11.1.2 Interfaces
11.1.3 Fluent APIs
11.1.4 Tuples
11.1.5 Out parameters
11.1.6 Object-based programming
11.1.7 F# wrappers
11.2 Exposing F# to C#
11.2.1 Core F# concepts
11.2.2 Tips and tricks
11.2.3 Introducing F# into existing codebases
11.3 Consuming NuGet packages
11.3.1 Working with NuGet package dependencies
11.3.2 Working with NuGet tools
11.4 The Fable project: F# and JavaScript
11.4.1 JavaScript to F#: A brief history
11.4.2 Introducing Fable
Summary
12 Asynchronous programming
12.1 What is asynchronous programming?
12.1.1 Async and sync programming
12.1.2 A brief history of async on .NET
12.2 Asynchronous support in F#
12.2.1 Tasks in .NET
12.2.2 Consuming Tasks
12.2.3 The task { } block: F#’s async/await
12.2.4 Executing multiple Tasks in parallel
12.2.5 Benefits of Tasks’ computation expressions
12.2.6 The async block
12.3 Final thoughts on asynchronous workloads
12.3.1 The importance of immutable data
12.3.2 The viral nature of asynchronous workloads
Summary
13 Web programming
13.1 The web and functional programming
13.1.1 Web programming on .NET and F#
13.1.2 The HTTP Context
13.2 Server-side web development in F#
13.2.1 Creating our first ASP.NET application
13.2.2 The HTTP Handler
13.2.3 Composing HTTP Handlers together
13.2.4 Composing multiple routes
13.2.5 Writing our own HTTP Handlers
13.2.6 Reading inputs
13.2.7 Validation
13.3 Functional patterns in a web application
13.4 Creating HTML views
13.4.1 Creating views through code
13.4.2 The ViewEngine DSL
13.4.3 Benefits of an F# DSL for HTML
13.5 Full-stack F# apps with SAFE Stack
13.5.1 Overview of SAFE Stack
13.5.2 Installing the SAFE Stack template
13.5.3 The MVU pattern
13.5.4 Removing all ToDo items: A worked exercise
Summary
14 Testing F# code
14.1 Automated tests: The value proposition
14.1.1 F#: Types over tests
14.2 Basic unit testing in F#
14.2.1 Tests as functions
14.2.2 Expecto
14.2.3 Plugging Expecto into our code
14.2.4 Advantages of Expecto
14.3 Making testable code
14.3.1 Preferring pure functions where possible
14.3.2 Preferring smaller functions
14.3.3 Unit testing small function hierarchies
14.3.4 Integration testing higher-level composed functions
14.3.5 Pushing side effects to the boundaries of your code
14.3.6 Using higher-order functions to replace side effects
14.3.7 Don’t worry about encapsulation
14.4 Working with NUnit-style test frameworks
14.5 Other forms of testing
14.5.1 Performance testing
14.5.2 Property-based testing
Summary
15 Pure functional programming
15.1 A functional architecture pattern
15.1.1 External and internal boundaries
15.1.2 Structuring larger functional codebases
15.2 Composing functions
15.2.1 The object-oriented approach to composition
15.2.2 Higher-order functions
15.2.3 Dependency rejection
15.2.4 Procedural composition
15.2.5 What should you use and when?
15.3 Working with low-level dependencies
15.3.1 A worked example: Working with a logging function
15.3.2 Flipping dependencies with a bootstrapper
15.3.3 Pros and cons of the wireup pattern
15.3.4 Applying the dependency rejection pattern
15.4 Working with effects
15.4.1 What are effects in F# and .NET?
15.4.2 Common effects in F#
15.4.3 Map and Bind
15.4.4 Using Computation Expressions to hide bind pipelines
Summary
16 Where next?
16.1 How do I start using F# in practice?
16.1.1 Data analysis
16.1.2 Hobby projects
16.1.3 Coding challenges
16.1.4 Before-and-after proof of concept
16.1.5 Operational scripts
16.2 How do I introduce F# to my team?
16.3 The F# community
16.3.1 Social media
16.3.2 Conferences and user groups
16.3.3 Open source
16.4 Advanced F# language features
16.4.1 Units of Measure
16.4.2 Active Patterns
16.4.3 Type Extensions
16.4.4 Implicit Conversions
16.4.5 Statically Resolved Type Parameters
16.4.6 Metaprogramming
Summary
index


📜 SIMILAR VOLUMES


F8F Bearcat in Action
✍ Charles L. Scrivner, Perry Manley, Don Greer 📂 Library 📅 1990 🏛 Squadron/Signal Publications 🌐 English

F8F Bearcat in Action - Aircraft No. 99 КНИГИ,ВОЕННАЯ ИСТОРИЯ Автор: Charles L. ScrivnerНазвание: F8F Bearcat in Action - Aircraft No. 99ISBN-10: 0897472438Издательство: Squadron/Signal PublicationsГод: 1990Формат: PDFРазмер: 9.7 MBЯзык: EnglishThe Grumman F8F Bearcat (affectionately called "Bear"

F4F Wildcat in Action
✍ Don Linn, Perry Manley, Don Greer 📂 Library 📅 1988 🏛 Squadron-Signal 🌐 English
F7F Tigercat in action
✍ USN (Ret.) Capt. W.E. Scarborough, Joe Sewell, Don Greer 📂 Library 📅 1986 🏛 Squadron/Signal publications 🌐 English

F7F Tigercat in action КНИГИ ;ВОЕННАЯ ИСТОРИЯ Издательство: Squadron/Signal publicationsСерия: Aircraft 79Автор(ы): Captain W E Scarborough USN (Ret.)Язык: EnglishГод издания: 1986Количество страниц: 51ISBN: 0-89747-188-1Формат: pdf (150 dpi) 1600x1200Размер: 42.8 mbRapid 34

F6F Hellcat in Action
✍ Jim Sullivan and Charles Scrivner 📂 Library 📅 2009 🏛 Squadron Signal Publications 🌐 English

F6F Hellcat in Action

F4F Wildcat In Action
✍ Richard S. Dann, Don Greer 📂 Library 📅 2004 🏛 SquadronSignal Publications 🌐 English

Extensive photos and illustrations showing aircraft details, variations, and configurations.

F-14 Tomcat in action
✍ Al Adcock, Perry Manley, Don Greer 📂 Library 📅 1990 🏛 Squadron/Signal Publications 🌐 English

F-14 Tomcat in action КНИГИ ;ВОЕННАЯ ИСТОРИЯ Издательство: Squadron/Signal publicationsСерия: Aircraft 105Автор(ы): Al AdcockЯзык: EnglishГод издания: 1990Количество страниц: 52ISBN: 0-89747-247-0Формат: pdf (72 dpi) 1160x920Размер: 15.7 mbSince the earliest days of carrier aviation, air cover for