The book uses an iterative structure. In part 1 we’ll explain a few aspects of the most important topics, so that you can see the motivation and understand what makes functional programming different. Part 2 systematically discusses all the foundations of functional programming. In part 3 we build on these foundations and talks about best practices for functional programming, optimization and some advanced techniques that most of the functional programmers occasionally need. Finally, part 4 presents more complex examples showing how to use functional programming to develop larger real-world projects.
Part I. Learning to think functionally
- Chapter 1 discusses the reasons why functional concepts are becoming increasingly important. It gives examples of existing technologies that you may already know and that benefit from some aspects of functional programming. It also shows the first sample application in F#.
- Chapter 2 introduces the concepts behind functional programming. Without showing any details and mostly using C#, it’ll help you understand how these concepts relate to each other and what they mean for the structure of program.
- Chapter 3 finally shows some real functional code. It demonstrates some data types used in F# such as a tuple and a list. We’ll see how to work with the types in F#, but we’ll also implement them in C# to explain how they work. This chapter introduces the idea of using functions as values, which is essential for functional programming.
- Chapter 4 shows our first real-world application implemented in F#. We’ll use various .NET and F# libraries to implement a program for drawing pie charts. You’ll also see how to efficiently use the tools F# provides during the development process.
Part II. Fundamental Functional Techniques
- Chapter 5 talks about values. Functional programs are written as calculations that take values as arguments and return values as results, so it is easy to see why we have to start the systematic review of functional features by looking at various kinds of values.
- Chapter 6 describes the most common way of working with values, which is to use higher-order functions. Working with values directly often requires a lot of repetitive code, so this chapter shows how to design and implement reusable operations.
- Chapter 7 turns the attention to architectural aspects. The structure of a functional
application is determined by the data that it works with. We’ll use an application that manipulates and draws simple documents to demonstrate this important principle.
- Chapter 8 focuses on the architecture of applications that need to dynamically change their behavior at runtime. This can be done using functions, so we’ll talk about them in detail and we’ll also explain related topics such as closures.
Part III. Advanced F# programming
- Chapter 9 shows how to mix object-oriented and functional styles in F#. It demonstrates how you can use functional features like immutability with object-oriented concepts such as encapsulation when writing functional .NET libraries.
- Chapter 10 focuses on correctness and efficiency. We’ll see how to write functions that can process data sets of arbitrary size and how to write these functions efficiently. You’ll also learn how to optimize code using imperative constructs like arrays.
- Chapter 11 talks about refactoring, testing and laziness. We’ll explain how functional programming makes it easier to understand and improve existing code. We’ll also look at unit testing, seeing how composability and strictness remove the need for some types of test.
- Chapter 12 starts by showing how we can work with collections of data. We’ll introduce F# sequence expressions, which are designed for this purpose. However, you’ll also see that this isn’t a built-in feature unlike its
closest counterpart in C# – it’s an example of a more general ability to change what code means.
Part IV. Applied functional programming
- Chapter 13 presents a common scenario when working with data in F#. It starts by downloading data using a public web service, then parses it into a structured format. Finally we see how to visualize interesting aspects using Excel.
- Chapter 14 shows how to use functional concepts to build applications that are easy to parallelize. It demonstrates this using an image processing application and a simulation featuring animals and predators that hunt them.
- Chapter 15 describes how to build declarative functional libraries. The chapter shows that well designed libraries can be elegantly composed. As an example, we’ll see how to create a library for creating animations and a library for representing financial contracts.
- Chapter 16 presents the last topic of the book. It shows how to build GUI applications and in general, programs driven by external events. Implementing control flow like this is quite difficult in other languages, so we’ll look at tricks that make it much easier in F#.