diff options
Diffstat (limited to 'examples/Main.lhs')
-rw-r--r-- | examples/Main.lhs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/examples/Main.lhs b/examples/Main.lhs new file mode 100644 index 00000000..7d798bfc --- /dev/null +++ b/examples/Main.lhs | |||
@@ -0,0 +1,32 @@ | |||
1 | A very helpful and literate comment. | ||
2 | % A very helpful comment for very helpful and very literate comment. | ||
3 | \begin{code} | ||
4 | module Main (main) where | ||
5 | |||
6 | import Control.Monad | ||
7 | import Network.BitTorrent | ||
8 | import System.Environment | ||
9 | import Control.Monad.Trans | ||
10 | |||
11 | |||
12 | main :: IO () | ||
13 | main = do | ||
14 | [path] <- getArgs | ||
15 | torrent <- fromFile path | ||
16 | |||
17 | print (contentLayout "./" (tInfo torrent)) | ||
18 | |||
19 | client <- newClient 2 [] | ||
20 | swarm <- newLeecher client torrent | ||
21 | |||
22 | storage <- swarm `bindTo` "/tmp/" | ||
23 | |||
24 | ppStorage storage >>= print | ||
25 | |||
26 | discover swarm $ do | ||
27 | liftIO $ print "connected to peer" | ||
28 | forever $ do | ||
29 | liftIO (getCurrentProgress client >>= print) | ||
30 | exchange storage | ||
31 | liftIO $ print "disconnected" | ||
32 | \end{code} \ No newline at end of file | ||