summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam T <pxqr.sta@gmail.com>2013-06-11 05:01:40 +0400
committerSam T <pxqr.sta@gmail.com>2013-06-11 05:01:40 +0400
commiteba89394fa87256fd2ec71b67e667032e9e765dd (patch)
tree45d97e83bcdc05a9a51cec2edffe256949df1426
parent64de83063c21a963b9c7cdec82cfe2b036166c15 (diff)
~ Add exsamples.
-rw-r--r--bittorrent.cabal5
-rw-r--r--exsamples/Main.hs20
2 files changed, 25 insertions, 0 deletions
diff --git a/bittorrent.cabal b/bittorrent.cabal
index 6266b63b..b4da98a4 100644
--- a/bittorrent.cabal
+++ b/bittorrent.cabal
@@ -102,6 +102,11 @@ library
102 cpp-options: -DTESTING 102 cpp-options: -DTESTING
103 ghc-options: -Wall 103 ghc-options: -Wall
104 104
105executable exsample
106 main-is: Main.hs
107 hs-source-dirs: exsamples
108 build-depends: base == 4.*
109 , bittorrent
105 110
106 111
107test-suite info-hash 112test-suite info-hash
diff --git a/exsamples/Main.hs b/exsamples/Main.hs
new file mode 100644
index 00000000..3a347ab6
--- /dev/null
+++ b/exsamples/Main.hs
@@ -0,0 +1,20 @@
1module Main (main) where
2
3import Data.Bitfield
4import Network.BitTorrent
5import System.Environment
6
7
8main :: IO ()
9main = do
10 [path] <- getArgs
11 Right torrent <- fromFile path
12
13 client <- newClient []
14 swarm <- newLeacher client torrent
15
16 discover swarm $ \se -> do
17 peers <- getPeerList se
18 print peers
19
20 print "Bye-bye!" \ No newline at end of file