Chapter 9. Turning values into F# object types with members
This chapter covers
- Declaring types with members
- Using interfaces in a functional way
- Writing class and interface types
- Using F# code from C#
When we introduced F# in chapter 1, we described it as a multiparadigm language that takes the best elements of several worlds. Most importantly, it takes ideas from both functional and object-oriented languages. In this chapter, we’re going to look at several features inspired by OOP or that allow fluent integration with object-oriented .NET languages like C# and Visual Basic .NET (VB.NET).
This chapter is particularly important for the later steps in the F# development process. As we’ve mentioned, functional simplicity allows us to write a program quickly and provides great flexibility. OOP in F# is valuable because it gives the code a solid structure, encapsulates related functionality, and allows painless integration with other systems or .NET programming languages. In this chapter, we’ll see how to take F# code that we developed earlier and evolve it to make it easier to use in a team or in a larger project.