StoreItem { String title; int yearPublished; double price; } public class Book extends StoreItem { Author author; String isbn; } public class VinylRecord extends StoreItem { String artist; }
book price (RecordItem record) = recordPrice record price (ToyItem toy) = toyPrice toy https://medium.com/@willkurt/why-sum-types-matter-in-haskell-ba2c1ab4e372