Chapter 5.  Algebraic Data Types

In this chapter, I turn to the F# features that are (almost) missing among mainstream programming languages, such as C#, that are collectively referred to in computer science as algebraic data types (https://en.wikipedia.org/wiki/Algebraic_data_type). They advance primitive data types to the higher type level with the help of the composition of other types (primitive or in-turn composite) which are as follows:

  • Tuples and records that represent product algebraic data types
  • Discriminated unions that represent sum algebraic types

I'll cover the same facets for each of these composite types as follows:

  • Type composition
  • Type equality and comparison
  • Type decomposition
  • Type augmentation

I will revisit the pattern matching as ...

Get F# 4.0 Design Patterns now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.