在IO中运行Distributed-process的Process类型

时间:2016-04-07 11:57:07

标签: haskell distributed

我正在尝试从distributed-process文档中运行channelsDemo,但当我尝试从channelsDemo运行main时,如下所示:

main = channelsDemo

我收到以下错误:

  

无法将预期类型IO ()与实际类型Process ()

匹配

以下是channelsDemo功能:

channelsDemo :: Process ()
channelsDemo = do
    (sp, rp) <- newChan :: Process (SendPort String, ReceivePort String)

    -- send on a channel
    spawnLocal $ sendChan sp "hello!"

    -- receive on a channel
    m <- receiveChan rp
    say $ show m

我看到了问题,但无法弄清楚如何修复它。

1 个答案:

答案 0 :(得分:4)

distributed-process有一个runProcess函数,似乎有正确的签名:

runProcess :: LocalNode -> Process () -> IO ()

并且可以创建LocalNode

newLocalNode :: Transport -> RemoteTable -> IO LocalNode