我有一个函数,它的签名涉及一些IO操作:
member this.IsRestaurantInCategoryAsync(restaurantName: string, restaurantAddress: string, restaurantCategory: string) =
async { ///long running methods }
我希望能在一个匿名函数中调用它,代码如下:
this.GetRestaurants()
|> Seq.filter(fun (name, address) -> categoryRepository.IsRestaurantInCategoryAsync(name, address, category))
|> Seq.toList
问题在于IsRestaurantInCategoryAsync返回的是async<bool>而不是bool。我该如何处理Seq.Filter呢?
我应该使用let!将async<bool>转换为bool,然后编写一个非匿名函数来分配返回值吗?