summaryrefslogtreecommitdiff
path: root/examples/Main.lhs
blob: 1a7b5b123a688e89d8b297e26ee523b041367ef9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
A very helpful and literate comment.
A very helpful comment for very helpful and very literate comment.

> module Main (main) where

> import Control.Monad
> import Network.BitTorrent
> import System.Environment
> import Control.Monad.Trans


> main :: IO ()
> main = do
>   [path]  <- getArgs
>   torrent <- fromFile path
>
>   print (contentLayout "./" (tInfo torrent))
>
>   client  <- newClient 2 []
>   swarm   <- newLeecher  client torrent
>
>   storage <- swarm `bindTo`  "/tmp/"
>
>   ppStorage storage >>= print
>
>   discover swarm $ do
>     liftIO $ print "connected to peer"
>     forever $ do
>       liftIO (getCurrentProgress client >>= print)
>       exchange storage
>     liftIO $ print "disconnected"