Chapter 11. F# Expert Techniques

So far in the book, we've dealt mostly with customary F# facilities that constitute the core of successful F# idiomatic use in diverse application fields. The common sign of (almost) all of the related usage patterns is that they are straightforward and ordinary. Their mastery is a must for any intermediate level F# practitioner.

In this chapter, I'm going to step out of the regular space where expressions always yield results, calculations take place sequentially, and code must be first written in order to be later used. I will walk you through some of expert level F# techniques, the area of exciting usage patterns that is often considered overcomplicated and error-prone in nonfunctional paradigms.

In this chapter I will cover the following topics in the context of F# idiomatic use:

  • Type providers
  • Concurrent programming
  • Reactive programming
  • Metaprogramming

I will approach each of these subjects by giving a brief overview accompanied with a concise usage sample taken from the enterprise trenches. I will attempt to show that these features are not really mind-bending and usually offer developers a strong safety net. However, please do not expect any sort of deep dive into these subjects. Consider the contents of this chapter more a roadmap to become skillful in these F# use patterns, as stimuli and practical application teasers.

A note on custom computation expressions

I've decided not to cover arbitrary F# Computation Expressions (https://docs.microsoft.com/en-us/dotnet/articles/fsharp/language-reference/computation-expressions) in this book despite F# itself having this mechanism baked in under the hood of significant language features, such as sequence expressions (covered in Chapter 6, Sequences - The Core of Data Processing Patterns), query expressions (covered in Chapter 9, More Data Crunching), and asynchronous expressions (to be addressed in this chapter). Although custom computation expressions allow crafting very elegant code in some cases, I feel that covering this feature here may divert us from the practicality path we are pursuing.

Note

Those of you interested in a solid understanding and mastery of the F# computation expressions may turn to this excellent detailed reading on the subject by Scott Wlaschin: The "Computation Expressions" series (https://fsharpforfunandprofit.com/series/computation-expressions.html).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset