gpt4 book ai didi

parallel-processing - Elm 中有并行性吗?

转载 作者:行者123 更新时间:2023-12-04 12:51:11 28 4
gpt4 key购买 nike

可以在 Elm 中编写并行代码吗? Elm 是纯函数式的,因此不需要锁定。当然,我可以使用 Javascript FFI,在这里生成 worker 并自己完成。但是,我想要更多用户友好的“方式”来做到这一点。

最佳答案

简答

不,目前没有。但是下一个版本 (0.15) 版本将提供处理 Elm 内部效果的新方法,因此您将需要更少地使用端口 + JavaScript 代码。因此,在下一个版本中,很可能有一种方法可以在 Elm 内部生成 worker 。

更多背景

如果您喜欢冒险,请尝试阅读 published paper on Elm (或更长的 original thesis ),这表明 Elm 使用的原始 FRP 风格非常适合细粒度并发。还有一个async可能使程序的一部分以更粗粒度的方式单独运行的构造。这可能是对操作系统级线程(如 JS Webworkers)和并行性的支持。

已有earlier experiments with Webworkers .社区内当然对并发很感兴趣,但是 JavaScript 没有为并发提供 (m) 任何很好的选择。

有关论文的阅读提示,请访问 post of mine from the elm-discuss mailing list :

If you want to know more about signals and opt-in async, I suggest you try Evan's PLDI paper on Elm. Read from the introduction (1) up to building GUIs (4). You can skip the type system (3.2) and functional evaluation (3.3.1), that may save you some time. Most in and after building GUIs (4) is probably stuff you know already. Figure 8 is probably the best overview of what the async keyword does (note that the async keyword is not implemented in the current Elm compiler).

关于parallel-processing - Elm 中有并行性吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29181960/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com