Introduction
In this post we are going to see how we can utilise some of the object programming features that F# offers. F# is a functional-first language but sometimes it is beneficial to use objects, particularly when interacting with code written in other, less functional, .Net languages or when you want to encapsulate some internal data structures and/or mutable state.
F# can do pretty much anything that C#/VB.Net can do with objects. We are going to concentrate on the core object programming features; class types, interfaces, encapsulation and equality.
Setting Up
Open VSCode and add a new folder. Add three new files (FizzBuzz.fs, RecentlyUsedList.fs and Coordinate.fs).
Solving the Problem
We will start in fizzbuzz.fs where we will be implementing FizzBuzz using object programming.
Add a module to the top of the page: