h$      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmno(c) Sam Truzjan 2013BSD3pxqr.sta@gmail.comstableportable Safe-Inferred8  bencodingBDictMap is an ascending list of key/value pairs sorted by keys. bencodingO(1). The empty dicionary. bencodingO(1)#. Dictionary of one key-value pair. bencodingO(1). Is the dictionary empty? bencodingO(n)(. Is the key a member of the dictionary? bencodingO(n).. Lookup the value at a key in the dictionary.  bencodingO(n + m). Merge two dictionaries by taking pair from both given dictionaries. Dublicated keys are not filtered.  bencodingO(n).2 Map a function over all values in the dictionary.  bencodingO(n).< Map a function over all keys/value pairs in the dictionary.  bencodingO(n). Map each key/value pair to a monoid and fold resulting sequnce using p.  bencodingO(n). Map each key/value pair to a monoid and fold resulting sequnce using p. bencodingO(n). Build a dictionary from a list of key/value pairs where the keys are in ascending order. bencodingO(n). Convert the dictionary to a list of key/value pairs where the keys are in ascending order.  (c) Sam Truzjan 2013BSD3pxqr.sta@gmail.comstableportable Safe-Inferred8   bencoding is straightforward ADT for b-encoded values. Please note that since dictionaries are sorted, in most cases we can compare BEncoded values without serialization and vice versa. Lists is not required to be sorted through. bencodingbencode integers; bencodingbencode strings; bencodinglist of bencode values; bencodingbencode key-value dictionary. bencodingA bencode dictionary.  bencodingA plain bencode list.! bencodingA raw bencode string." bencodingA bencode "integer".# bencoding%Test if bencoded value is an integer.$ bencoding>Test if bencoded value is a string, both raw and utf8 encoded.% bencoding!Test if bencoded value is a list.& bencoding'Test if bencoded value is a dictionary.  !"#$%& "! #$%&(c) Sam Truzjan 2013BSD3pxqr.sta@gmail.comstableportableNone .- bencoding2BEncode format encoder according to specification.. bencodingConvert bencoded value to raw bytestring according to the specification./ bencoding1BEncode format parser according to specification.0 bencodingTry to convert raw bytestring to bencoded value according to specification.1 bencodingConvert to easily readable JSON-like document. Typically used for debugging purposes.-./01/0-.1(c) Sam Truzjan 2013BSD3pxqr.sta@gmail.comstableportable Trustworthy 9>?62 bencodingDictionary extractor are similar to dictionary builders, but play the opposite role: they are used to define 6. method in declarative style. Using the same FileInfo datatype the 6 function instance looks like:  instance 4 FileInfo where 6 = H $ do FileInfo D "length" G "md5sum" F "path" G "tags" The reqKey is used to extract required key @ if lookup is failed then whole destructuring fail.NOTE: the actions MUST be sorted lexicographically by keys, like so: "length" q "md5sum" q "path" q "tags"3 bencodingAssoc used to easily build dictionaries with required and optional keys. Suppose we have we following datatype we want to serialize:  data FileInfo = FileInfo { fileLength :: Integer , fileMD5sum :: Maybe ByteString , filePath :: [ByteString] , fileTags :: Maybe [Text] } deriving (Show, Read, Eq) We need to make  instance 4 FileInfo*, though we don't want to check the both rs manually. The more declarative and convenient way to define the 5' method is to use dictionary builders:  instance 4 FileInfo where 5 FileInfo {..} = < $ "length" 9 fileLength ; "md5sum" : fileMD5sum ; "path" 9 filePath ; "tags" : fileTags ; = NOTE: the list of pairs MUST be sorted lexicographically by keys, like so: "length" q "md5sum" q "path" q "tags"4 bencodingThis class is used to define new datatypes that could be easily serialized using bencode format. By default 4 have a generic implementation; suppose the following datatype: data List a = C { _head :: a , __tail :: List a } | N deriving GenericIf we don't need to obey any particular specification or standard, the default instance could be derived automatically from the s instance: &instance BEncode a => BEncode (List a)Example of derived 5 result: > toBEncode (C 123 $ C 1 N) BDict (fromList [("head",BInteger 123),("tail",BList [])])Note that prefixed underscore characters are omitted since they are usually used for lens.5 bencoding&See an example of implementation here 36 bencoding&See an example of implementation here 2.7 bencoding#Result used in decoding operations.8 bencodingTypically used to throw an decoding error in fromBEncode; when BEncode value to match expected value.9 bencodingMake required key value pair.: bencoding Like the (9) operator but if the value is not present then the key do not appear in resulting bencode dictionary.; bencodingCons a key/value pair.< bencoding1Make a bencode value from dictionary description.= bencoding'Used to specify end of dictionary. See 3.> bencodingRun action, but return without consuming and key/value pair. Fails if the action fails.? bencoding?@ABCDEFGHIJ456JI39:;=<278H>?@ABCDEFG96:6;5D4E4F4G4      !"##"! $%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvqwxqyzq{|q}~qrq(bencoding-0.4.5.4-Ic8uEnTnzRDLifDnGgHPhIData.BEncode.BDictData.BEncode.TypesData.BEncode.Internal Data.BEncodeBDictMapConsNilBKeyempty singletonnullmemberlookupunionmap mapWithKeyfoldMapWithKey bifoldMap fromAscList toAscList$fMonoidBDictMap$fSemigroupBDictMap$fFoldableBDictMap$fFunctorBDictMap$fNFDataBDictMap$fShowBDictMap$fReadBDictMap $fEqBDictMap $fOrdBDictMap$fGenericBDictMapBValueBIntegerBStringBListBDict isIntegerisStringisListisDict$fNFDataBValue $fShowBValue $fReadBValue $fEqBValue $fOrdBValue$fGenericBValuebuilderbuildparserparse ppBEncodeGetAssocBEncode toBEncode fromBEncodeResult decodingError.=!.=?.:toDictendDict lookAheadnextreqoptfieldmatch<$>!<$>?<*>!<*>?fromDictdecodeencode$fGBEncodableM1e$fGBEncodableM1BValue$fGBEncodableM1[]$fGBEncodableM1BDictMap$fGBEncodable:+:e$fGBEncodable:*:BDictMap$fGBEncodable:*:[]$fGBEncodableU1e$fBEncode(,,,,)$fBEncode(,,,) $fBEncode(,,) $fBEncode(,) $fBEncode()$fBEncodeVersion $fBEncode[] $fBEncodeText $fBEncodeBool $fBEncodeInt$fBEncodeInt64$fBEncodeInt32$fBEncodeInt16 $fBEncodeInt8 $fBEncodeWord$fBEncodeWord64$fBEncodeWord32$fBEncodeWord16$fBEncodeWord8$fBEncodeBDictMap$fBEncodeByteString$fBEncodeInteger$fBEncodeBValue$fGBEncodableK1BValue$fMonadFailGet $fMonadGet $fFunctorGet$fApplicativeGet$fAlternativeGetbaseGHC.Basemappendghc-prim GHC.Classes< GHC.MaybeMaybe GHC.GenericsGeneric Data.Functor<$>Control.Applicativeoptional<*>bytestring-0.10.10.0Data.ByteString.Internal ByteStringControl.Monad.Failfail