Skip to content

Instantly share code, notes, and snippets.

@mikhailshilkov
Created December 19, 2018 23:00
Show Gist options
  • Save mikhailshilkov/baa1e6fec15dea2e8b867bafdf61f0e2 to your computer and use it in GitHub Desktop.
Save mikhailshilkov/baa1e6fec15dea2e8b867bafdf61f0e2 to your computer and use it in GitHub Desktop.
// WishList -> Async<Reservation>
let workflow (wishlist: WishList) = async {
// 1. Find matches for each wish
let! matches =
wishlist.Wishes
|> List.map findMatchingGift
|> Async.Parallel
// 2. Pick one product from the combined list of matches
let gift = pickGift (List.concat matches)
// 3. Register and return the reservation
let reservation = { Kid = wishlist.Kid; Product = gift }
do! reserve reservation
return reservation
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment