Skip to content

Commit e0eb9ad

Browse files
committed
Merge pull request #4 from k-bx/patch-2
Update on createTransport semantics (return value) and more. Thanks @k-bx
2 parents 9acf70a + e9f3b59 commit e0eb9ad

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

tutorials/tutorial1.md

+16-8
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,21 @@ from other nodes. We'll look at inter-node communication later, so for now
3333
it will suffice to pass the default remote table, which defines the built-in
3434
stuff 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+
3644
Our TCP network transport backend needs an IP address and port to get started
3745
with, and we're good to go...
3846

3947
{% highlight haskell %}
4048
main :: IO ()
4149
main = 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

6876
Lightweight 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 %}
8492
main :: IO ()
8593
main = 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

Comments
 (0)