January 2018
Beginner to intermediate
312 pages
7h 22m
English
When we documented our domain, we used AND and OR to represent more complex models. In Chapter 4, Understanding Types, we learned about F#’s algebraic type system and saw that it also used AND and OR to create complex types from simple ones.
Let’s now take the obvious step and use the algebraic type system to model our domain.
In our domain, we saw that many data structures were built from AND relationships. For example, our original, simple Order was defined like this:
| | data Order = |
| | CustomerInfo |
| | AND ShippingAddress |
| | AND BillingAddress |
| | AND list of OrderLines |
| | AND AmountToBill |
This translates directly to an F# record structure, like this:
| | type Order = { |
| | CustomerInfo : CustomerInfo ... |
Read now
Unlock full access