我想在Haskell中建模一个生物系统。我想这样做。
在Haskell中推荐的方法是什么?我非常了解基本的Haskell。 Monad和Arrows也很舒服。当我阅读反应性香蕉库时,我可以掌握很多。
答案 0 :(得分:2)
你描述的东西似乎是the actors model。这是Erlang编程语言的基础,但Haskell没有内置的actor原语。 Quick Cabal检查提供hactors
和simple-actors
,但我无法详细说明。
答案 1 :(得分:1)
如果您想在Haskell中使用actor系统,我强烈建议您查看Cloud Haskell。它基于Erlang / OTP(提供相同的消息传递并发语义和故障处理)。
警告:我是维护者。 ;)
https://github.com/haskell-distributed http://haskell-distributed.github.io
答案 2 :(得分:1)
这里的其他人都提到过演员,所以我想提及pipes-concurrency
,这是一种非分布式的演员。
与演员一样,您可以spawn
邮箱:
import Pipes
import Pipes.Concurrent
import qualified Pipes.Prelude
main = do
(output, input) <- spawn Unbounded
...
...向邮箱发送邮件:
forkIO $ runEffect $ Pipes.Prelude.stdinLn >-> toOutput output
...并从邮箱中读取邮件:
runEffect $ runEffect $ fromInput input >-> Pipes.Prelude.stdoutLn
您甚至不必使用pipes
界面。您可以使用send
:
send :: Output a -> a -> STM Bool
...并使用recv
recv :: Input a -> STM (Maybe a)
附带一个extended tutorial,解释了如何使用该库。