@@ -33,13 +33,21 @@ from other nodes. We'll look at inter-node communication later, so for now
3333it will suffice to pass the default remote table, which defines the built-in
3434stuff Cloud Haskell needs at a minimum.
3535
36+ Let's start with imports first:
37+
38+ {% highlight haskell %}
39+ import Network.Transport.TCP (createTransport, defaultTCPParameters)
40+ import Control.Distributed.Process
41+ import Control.Distributed.Process.Node
42+ {% endhighlight %}
43+
3644Our TCP network transport backend needs an IP address and port to get started
3745with, and we're good to go...
3846
3947{% highlight haskell %}
4048main :: IO ()
4149main = do
42- Right (t, _ ) <- createTransport "127.0.0.1" "10501" defaultTCPParameters
50+ Right t <- createTransport "127.0.0.1" "10501" defaultTCPParameters
4351 node <- newLocalNode t initRemoteTable
4452 ....
4553{% endhighlight %}
@@ -57,12 +65,12 @@ will send one to ourselves!
5765{% highlight haskell %}
5866-- in main
5967 _ <- forkProcess node $ do
60- -- get our own process id
61- self <- getSelfPid
62- send self "hello"
63- hello <- expect :: Process String
64- liftIO $ putStrLn hello
65- return ()
68+ -- get our own process id
69+ self <- getSelfPid
70+ send self "hello"
71+ hello <- expect :: Process String
72+ liftIO $ putStrLn hello
73+ return ()
6674{% endhighlight %}
6775
6876Lightweight processes are implemented as ` forkIO ` threads. In general we will
@@ -83,7 +91,7 @@ Let's spawn another process on the same node and make the two talk to each other
8391{% highlight haskell %}
8492main :: IO ()
8593main = do
86- Right (t, _ ) <- createTransport "127.0.0.1" "10501" defaultTCPParameters
94+ Right t <- createTransport "127.0.0.1" "10501" defaultTCPParameters
8795 node <- newLocalNode t initRemoteTable
8896 _ <- forkProcess node $ do
8997 echoPid <- spawnLocal $ forever $ do
0 commit comments