令参数和管道运营权 [英] Order of arguments and pipe-right operator

查看:164
本文介绍了令参数和管道运营权的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法来简化以下,所以我不会需要一个runWithTimeout功能?

 让runWithTimeout超时计算=
   Async.RunSynchronously(计算,超时)

让processOneItem项目= fetchAction项目
                           |> runWithTimeout 2000
 

编辑: 这也是为什么我需要额外的方法:

 让processOneItem项目= fetchAction项目
                           |> Async.Catch
                           |> runWithTimeout 2000
                           |> handleExceptions
 

解决方案

也许你的意思是这样的:

 让processOneItem项目=
  fetchAction项目
  |>有趣x  - > Async.RunSynchronously(X,2000年)
 

Is there a way to simplify the following, so I won't need a runWithTimeout function?

let runWithTimeout timeout computation =
   Async.RunSynchronously(computation, timeout)

let processOneItem item =  fetchAction item
                           |> runWithTimeout 2000

Edit: Here's why i needed the extra method:

let processOneItem item =  fetchAction item
                           |> Async.Catch
                           |> runWithTimeout 2000
                           |> handleExceptions

解决方案

Perhaps you mean something like this:

let processOneItem item =
  fetchAction item
  |> fun x -> Async.RunSynchronously(x, 2000)

这篇关于令参数和管道运营权的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆