July 2023
Intermediate to advanced
670 pages
17h 13m
English
One of the most common reasons to make your own data types in Haskell is to create named and structured collections of some other types. For example, you might want to create a type that represents some information about a customer like their first and last name, the number of products they’ve ordered, and their current outstanding account balance. You can create a new type with the data keyword. For example, to create a new CustomerInfo you can simply say:
| | data CustomerInfo |
This defines the existence of a new type called CustomerInfo. Unfortunately, as we’ve written the code, the only thing it does is define a new type. We don’t have any way to create a value of our new type, in other words we’ve created ...
Read now
Unlock full access