Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
At the beginning of this book, we said functional programming is built on top of very different foundations than those you were used to. After reading part 1, you should have an idea of how to build programs using principles like immutability and recursion. We’ve also seen basic types such as tuples and lists and used them to write our first larger functional application. Now that you know how functional concepts fit together, we can take a more systematic look at the basic building blocks that F# and other functional languages provide.
In F# you often start by experimenting using only basic functional features. This way, you can quickly get to code that works and try various approaches before choosing the best solution. In part 2 we’ll review all the basic functional features that make it possible to write the first version of program. We’ve seen the tuple type as one example of a simple functional data structure, but there are other types and other ways of working with them.
In part 2 we’ll review all the basic functional features that make it possible to write the first version of program.
In chapter 5, we’ll distinguish between values and data. Values are used locally in the program, such as a tuple returned from a function that performs division with a remainder. A list of tuples storing items in a pie chart (from chapter 4) is an example of data, because it’s a major data structure used by the whole application.
We’ll also review the data types used for declaring and creating functional values and explore how to work with these values.
In chapter 6, we’ll still focus on values, but look at a more convenient way of calculating with them using higher-order functions: functions that take other functions as an argument.
In chapters 7 and 8, we’ll shift focus to architectural aspects of functional programming, exploring ways for representing and working with data. We’ll make a distinction between data-centric and behavior-centric applications. In chapter 7, we’ll discuss applications whose design is determined by the data they work with, and in chapter 8 we’ll discuss applications whose primary data structure represents some form of behavior. We’ll see connections between structural object-oriented design patterns and the data-centric programs in chapter 7, as well as between behavioral patterns and behavior-centric applications in chapter 8.
By the end of part 2, you’ll understand all functional types and how to use them in real-world functional design. You’ll be able to think differently about your programming tasks, because you’ll be familiar with all the functional constructs that determine the way applications are structured and written.
In parts 3 and 4, we’ll look at what can be improved and at more real-world examples, but the concepts from this part will remain as solid foundations.