]> git.rkrishnan.org Git - functorrent.git/blobdiff - src/FuncTorrent/Bencode.hs
*.hs: add GPLv3 License text and copyright notice
[functorrent.git] / src / FuncTorrent / Bencode.hs
index 8b6ff5229909266a42e85bb4a47952f32afe7af8..96cdd653c95d7cd2246c419156c72c4234f0d6d5 100644 (file)
@@ -1,4 +1,23 @@
 {-# LANGUAGE OverloadedStrings #-}
+{-
+Copyright (C) 2015-2016 Ramakrishnan Muthukrishnan <ram@rkrishnan.org>
+
+This file is part of FuncTorrent.
+
+FuncTorrent is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3 of the License, or
+(at your option) any later version.
+
+FuncTorrent is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with FuncTorrent; if not,  see <http://www.gnu.org/licenses/>
+-}
+
 module FuncTorrent.Bencode
     (BVal(..)
     , bValToBList
@@ -12,10 +31,8 @@ module FuncTorrent.Bencode
 
 import Prelude hiding (length, concat)
 
-import Control.Applicative ((<*))
 import Data.ByteString (ByteString, length, concat)
 import Data.ByteString.Char8 (unpack, pack)
-import Data.Functor ((<$>))
 import Data.Map.Strict (Map, fromList, toList)
 import Text.ParserCombinators.Parsec
 import qualified Text.Parsec.ByteString as ParsecBS
@@ -38,9 +55,9 @@ instance Arbitrary BVal where
                                , Bstr <$> arbitrary]
                 bval n = oneof [ Bint <$> arbitrary
                                , Bstr <$> arbitrary
-                               , Blist <$> vectorOf n arbitrary
+                               , Blist <$> vectorOf n (bval (n `div` 4))
                                , do keys <- vectorOf n arbitrary
-                                    vals <- vectorOf n arbitrary
+                                    vals <- vectorOf n (bval (n `div` 4))
                                     return $ Bdict $ fromList $ zip keys vals ]
 
 -- getters