Haskell期货 [英] Futures in Haskell
本文介绍了Haskell期货的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Haskell是否等同于Alice将变量绑定到未来的能力?
Does Haskell have an equivalent of Alice's ability to bind a variable to a future?
val a = spawn foo;
其中foo是某些函数。
where foo is some function.
我知道Haskell支持渠道和线程;我希望语法和Alice的语法一样,将一个值绑定到一个未来,并产生一个线程来计算它,而不必处理细节。
I know Haskell supports channels and threads; I'm hoping for syntax as natural as Alice's to bind a value to a future and spawn a thread to calculate it without having to deal with the details.
推荐答案
您可以从 Control.Parallel
中使用 par
b
You can use par
from Control.Parallel
as in
a `par` f a b c
where
a = foo
这是对运行时的一个提示,可以在另一个线程中计算 a
。
This is a hint to the runtime that a
could be evaluated in another thread.
这篇关于Haskell期货的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文