ADTs

Algebraic data types are just composite types that combine other existing types or just represent some new ones. They only have data and do not contain any functionality on top of this data as normal classes would. Some examples can include the day of the week or a class that represents an RGB color—they have no extra functionality and they just carry information. The following few subsections will give a bit more insight on what ADTs are and what types are out there.

Get Scala Design Patterns - Second Edition 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.