fp-ddd chapter 5 Posted on 2020-08-21 | Domain Modeling Made Functional - Chapter 4Domain Modeling with Types we’re using a namespace in F# to indicate a DDD bounded context 123456789101112131415161718192021222324252627282930313233343536373839namespace OrderTaking.Domaintype Undefined = exntype WidgetCode = WidgetCode of stringtype GizmoCode = GizmoCode of stringtype ProductCode = | Widget of WidgetCode | Gizmo of GizmoCodetype UnitQuantikty = UnitQuantity of inttype KilogramQuantity = KilogramQuantity of decimaltype OrderQuantity = | Unit of UnitQuantity | Kilos of KilogramQuantitytype OrderId = Undefinedtype OrderLineId = Undefinedtype CustomerId = Undefinedtype CustomerInfo = Undefinedtype ShippingAddress = Undefinedtype ShippingAddress = Undefinedtype BillingAddress = Undefinedtype Price = Undefinedtype BillingAmount = Undefinedtype Order = { Id: OrderId // id for entity CustomerId: CustomerId // customer reference ShippingAddress: ShippingAddress BillingAddress: BillingAddress OrderLines: OrderLInt list AmountToBill: BillingAmount}and OrderLine = { Id: OrderLineID // id for entity} Workflow123456789101112131415161718192021222324252627// inputtype UnvalidatedOrder = { OrderId: string CustomerInfo: ... ShippingAddress: ...}// outputtype PlaceOrderEvents = { AcknowledgmentSent: ... OrderPlaced: ... BillableOrderPlaced: ...}// Errorstype PlaceOrderError = | ValidationError of ValidationError list | .. // other errorsand ValidationError = { FieldName: string ErrorDescription: string}// The "place order" processtype PlaceOrder = UnvalidatedOrder -> Result<PlaceOrderEvents, PlaceOrderError>