Skip to content

Instantly share code, notes, and snippets.

Embed
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
|> Result.map(fun p-> p.updateDimensions(height, length, weight, width))
|> Result.map 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
You can’t perform that action at this time.