Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Use case to update product dimensions with dependencies injected through the type constructor
type UpdateProductDimensions(dataStore: DataStore)=
//Other private methods removed for brevity
let updateDimensions(productId, height, length, weight, width)=
dataStore.getProduct productId
|> p-> p.updateDimensions(height, length, weight, width))
|> dataStore.updateProduct
member this.update (productId, (height,length,weight,width)) =
dataStore.productExists productId
|> Result.bind(function
| Some p -> updateDimensions(p, height, length, weight, width)
| None -> Error(new exn (sprintf "Product %i does not exist." productId)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment