O'Reilly logo

Get Programming with F#: A guide for .NET developers by Isaac Abraham

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Lesson 21. Modeling relationships in F#

Although you’ve looked at different ways of storing data in F# (tuples, records, and so forth), one thing you haven’t looked at much is how to model relationships of data together—for example, different types of motor vehicles such as cars, motorbikes, and vans. In this lesson, you’ll look at a way of doing this in F#, using a flexible and powerful modeling tool called discriminated unions. You’ll do the following:

  • Briefly review inheritance in the OO world
  • Learn what discriminated unions are, and how to use them
  • Compare and contrast inheritance and discriminated unions

You’re probably familiar with modeling relationships in C# already, through one of two mechanisms: composition and inheritance. The ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required