Book description
Learn how to apply functional F# design patterns to a huge range of programming challenges, and discover a smart route to building better applications
About This Book
This book provides a path if you are coming from imperative and object-oriented paradigms
It will take you to an intermediate level of functional programming in very practical manner to write enterprise-quality idiomatic F# code
Tackle complex computing problems with simple code by fully embracing the functional-first F# paradigm
Packed full of practical coding examples to help you master F# programming and author optimal code
Who This Book Is For
This book is for .NET developers, web programmers, C# developers, and F# developers. So, if you have basic experience in F# programming and developing performance-critical applications, then this book is for you.
What You Will Learn
Acquire the practical knowledge to use the main functional design patterns
Realign some imperative and object-oriented principles under the functional approach
Develop your confidence in building and combining first-order and higher-order functions
Learn to use core language pattern matching effectively
Make use of native F# algebraic data types in place of custom-built classes
Recognize and measure the difference in resource consumption between sequences and materialized data collections
Navigate and use F# Core libraries with ease by seeing patterns behind specific library functions
Master writing generic polymorphic code
In Detail
Following design patterns is a well-known approach to writing better programs that captures and reuses high-level abstractions that are common in many applications. This book will encourage you to develop an idiomatic F# coding skillset by fully embracing the functional-first F# paradigm. It will also help you harness this powerful instrument to write succinct, bug-free, and cross-platform code.
F# 4.0 Design Patterns will start off by helping you develop a functional way of thinking. We will show you how beneficial the functional-first paradigm is and how to use it to get the optimum results. The book will help you acquire the practical knowledge of the main functional design patterns, the relationship of which with the traditional Gang of Four set is not straightforward.
We will take you through pattern matching, immutable data types, and sequences in F#. We will also uncover advanced functional patterns, look at polymorphic functions, typical data crunching techniques, adjusting code through augmentation, and generalization. Lastly, we will take a look at the advanced techniques to equip you with everything you need to write flawless code.
Style and approach
This book will teach you how to write F# code in an idiomatic functional-first manner, thereby improving the productivity of F# programmers. This book is ideal for an F# programmer who wants using F# in functional-first way.
Table of contents
-
F# 4.0 Design Patterns
- F# 4.0 Design Patterns
- Credits
- About the Author
- Acknowledgements
- About the Reviewer
- www.PacktPub.com
- Preface
-
1. Begin Thinking Functionally
- Relationship between F# and programming paradigms
- A sample problem to solve
- Immutability of participating data entities
- Thinking in verbs rather than nouns
- "What" prevailing over "how"
- Generalization over specialization
- Minimizing moving parts over hiding them
- Reduction to known parts over producing custom parts
- Lazy over eager data collections
- Summary
-
2. Dissecting F# Origins and Design
- The evolvement of F#
-
Predecessor inherited language features
- F# functions are first-class entities
- Functions are free of side effects
- Functions can be curried and partially evaluated
- Functions may be anonymous
- Functions may be recursive
- Functions may raise exceptions
- Functions may reference external values
- F# is a statically typed language
- F# type inference provides type generalization
- F# supports parametric polymorphism
- F# inherits the variety of aggregate data structures from ML
- F# supports pattern matching
- F# supports data references
- Functions are non-recursive by default
- Modules
-
.NET-imposed language features
- F# adheres to .NET Common Language Infrastructure
- F# has nominal type system
- F# fully embraces .NET object orientation
- F# requires calling the method of an explicit interface
- Object expressions
- Reflection
- Extending classes and modules
- Enumerations
- Structures
- Events
- Nullable types
- Interoperation with the managed code
- Interoperation with unmanaged code
- Intrinsic F# language features
- Summary
- 3. Basic Functions
- 4. Basic Pattern Matching
- 5. Algebraic Data Types
- 6. Sequences - The Core of Data Processing Patterns
- 7. Advanced Techniques: Functions Revisited
-
8. Data Crunching – Data Transformation Patterns
- Core data transformation libraries in F# 4.0
-
Data transformation patterns
- The generation pattern
- The aggregation pattern
- The wrapping and type conversion pattern
- The selection pattern
- The searching pattern
- The partitioning pattern
- The reordering pattern
- The testing pattern
- The iterating pattern
- The mapping pattern
- The folding pattern
- The merge/split pattern
- Summary
- 9. More Data Crunching
- 10. Type Augmentation and Generic Computations
- 11. F# Expert Techniques
- 12. F# and OOP Principles/Design Patterns
- 13. Troubleshooting Functional Code
Product information
- Title: F# 4.0 Design Patterns
- Author(s):
- Release date: November 2016
- Publisher(s): Packt Publishing
- ISBN: 9781785884726
You might also like
book
Design Patterns in .NET: Reusable Approaches in C# and F# for Object-Oriented Software Design
Implement design patterns in .NET using the latest versions of the C# and F# languages. This …
book
Design Patterns in .NET Core 3: Reusable Approaches in C# and F# for Object-Oriented Software Design
Implement design patterns in .NET Core 3 using the latest versions of the C# and F# …
book
F# for C# Developers
Extend your C# skills to F#—and create data-rich computational and parallel software components faster and more …
book
Stylish F#: Crafting Elegant Functional Code for .NET and .NET Core
Why just get by in F# when you can program in style! This book goes beyond …