You are previewing Programming F#.

Programming F#

Cover of Programming F# by Chris Smith Published by O'Reilly Media, Inc.

Chapter 7. Applied Functional Programming

Most of the programming we have done so far has been in the functional style. While this has enabled us to write succinct, powerful programs, we haven’t quite used the functional style to its full potential. Functional programming means more than just treating functions as values. Embracing the functional programming paradigm and letting it help shape your thought process will enable you to write programs that would otherwise be prohibitively difficult in an imperative style.

In this chapter, we will build on what you learned about functional programming back in Chapter 3, and I’ll introduce new language features that will help you be more productive in the functional style. For example, using active patterns will allow you to increase the power of your pattern matching and eliminate the need for when guards; and by creating auto-opened modules,you can extend common F# modules.

In addition, we will look at some of the more mind-bending aspects of functional programming. You will learn how to use advanced forms of recursion to avoid stack overflows in your code and write more efficient programs using lists. And we will take a look at some common design patterns for functional code.

Our journey into exploring applied functional programming begins with looking at how you can harness the power of F#’s type checking and type inference systems to eliminate bugs in your code.

Units of Measure

There are several universal truths in this world: gravity ...

The best content for your career. Discover unlimited learning on demand for around $1/day.