summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam T <pxqr.sta@gmail.com>2013-07-08 04:52:10 +0400
committerSam T <pxqr.sta@gmail.com>2013-07-08 04:52:10 +0400
commitf7245e3cc7c5729b401bbbe3438a9f5b9dda211b (patch)
tree49e6bb1b0ef127e8540e32bb5369571dd66be333
parent83098eaf867b286048a41a16da47e5a1fd04d68d (diff)
~ Unliterate example.
-rw-r--r--bittorrent.cabal2
-rw-r--r--examples/Main.hs23
-rw-r--r--examples/Main.lhs23
3 files changed, 24 insertions, 24 deletions
diff --git a/bittorrent.cabal b/bittorrent.cabal
index 72673b35..8b1f967c 100644
--- a/bittorrent.cabal
+++ b/bittorrent.cabal
@@ -176,7 +176,7 @@ benchmark benchmarks
176 176
177 177
178executable example 178executable example
179 main-is: Main.lhs 179 main-is: Main.hs
180 hs-source-dirs: examples 180 hs-source-dirs: examples
181 build-depends: base == 4.* 181 build-depends: base == 4.*
182 , bittorrent 182 , bittorrent
diff --git a/examples/Main.hs b/examples/Main.hs
new file mode 100644
index 00000000..bc3fbb8b
--- /dev/null
+++ b/examples/Main.hs
@@ -0,0 +1,23 @@
1module Main (main) where
2
3import Control.Monad
4import Network.BitTorrent
5import Network.BitTorrent.Extension
6import System.Environment
7import Control.Monad.Trans
8
9main :: IO ()
10main = do
11 [path] <- getArgs
12 torrent <- fromFile path
13 print (contentLayout "./" (tInfo torrent))
14 client <- newClient 100 [ExtDHT]
15 swarm <- newLeecher client torrent
16 storage <- swarm `bindTo` "/tmp/"
17 ppStorage storage >>= print
18 discover swarm $ do
19 liftIO $ print "connected to peer"
20 forever $ do
21 liftIO (getCurrentProgress client >>= print)
22 exchange storage
23 liftIO $ print "disconnected"
diff --git a/examples/Main.lhs b/examples/Main.lhs
deleted file mode 100644
index 4d1c4eef..00000000
--- a/examples/Main.lhs
+++ /dev/null
@@ -1,23 +0,0 @@
1> module Main (main) where
2>
3> import Control.Monad
4> import Network.BitTorrent
5> import System.Environment
6> import Control.Monad.Trans
7>
8>
9> main :: IO ()
10> main = do
11> [path] <- getArgs
12> torrent <- fromFile path
13> print (contentLayout "./" (tInfo torrent))
14> client <- newClient 2 []
15> swarm <- newLeecher client torrent
16> storage <- swarm `bindTo` "/tmp/"
17> ppStorage storage >>= print
18> discover swarm $ do
19> liftIO $ print "connected to peer"
20> forever $ do
21> liftIO (getCurrentProgress client >>= print)
22> exchange storage
23> liftIO $ print "disconnected"