From f7245e3cc7c5729b401bbbe3438a9f5b9dda211b Mon Sep 17 00:00:00 2001 From: Sam T Date: Mon, 8 Jul 2013 04:52:10 +0400 Subject: ~ Unliterate example. --- bittorrent.cabal | 2 +- examples/Main.hs | 23 +++++++++++++++++++++++ examples/Main.lhs | 23 ----------------------- 3 files changed, 24 insertions(+), 24 deletions(-) create mode 100644 examples/Main.hs delete mode 100644 examples/Main.lhs diff --git a/bittorrent.cabal b/bittorrent.cabal index 72673b35..8b1f967c 100644 --- a/bittorrent.cabal +++ b/bittorrent.cabal @@ -176,7 +176,7 @@ benchmark benchmarks executable example - main-is: Main.lhs + main-is: Main.hs hs-source-dirs: examples build-depends: base == 4.* , 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 @@ +module Main (main) where + +import Control.Monad +import Network.BitTorrent +import Network.BitTorrent.Extension +import System.Environment +import Control.Monad.Trans + +main :: IO () +main = do + [path] <- getArgs + torrent <- fromFile path + print (contentLayout "./" (tInfo torrent)) + client <- newClient 100 [ExtDHT] + 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" 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 @@ -> 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" -- cgit v1.2.3