úÎ\ÓW\5      !"#$%&'()*+,-./01234portablestablepxqr.sta@gmail.com Safe-Inferred $BDictMap is an ascending list of key/value pairs sorted by keys. O(1). The empty dicionary. O(1)$. Dictionary of one key-value pair. O(1). Is the dictionary empty? O(n)). Is the key a member of the dictionary? O(n)/. Lookup the value at a key in the dictionary. O(n + m)8. Merge two dictionaries by taking pair from both given # dictionaries. Dublicated keys are not filtered. O(n).3 Map a function over all values in the dictionary. O(n). Map each key/*value pair to a monoid and fold resulting  sequnce using 5. O(n)'. Build a dictionary from a list of key/value pairs where " the keys are in ascending order. O(n)). Convert the dictionary to a list of key/ value pairs ( where the keys are in ascending order.  6789   6789portablestablepxqr.sta@gmail.com Safe-Inferred 5 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. bencode key-value dictionary. list of bencode values; bencode strings; bencode integers; A bencode dictionary. A plain bencode list. A raw bencode string.  A bencode integer. &Test if bencoded value is an integer. ?Test if bencoded value is a string, both raw and utf8 encoded. "Test if bencoded value is a list. (Test if bencoded value is a dictionary. :   :portablestablepxqr.sta@gmail.comNone;3BEncode format encoder according to specification. :Convert bencoded value to raw bytestring according to the  specification. <2BEncode format parser according to specification. =Try to convert raw bytestring to bencoded value according to  specification. BConvert to easily readable JSON-like document. Typically used for  debugging purposes. ;<=;<=portablestablepxqr.sta@gmail.com TrustworthyBDictionary extractor are similar to dictionary builders, but play , the opposite role: they are used to define " method in # declarative style. Using the same FileInfo datatype the  " function instance looks like:  $ instance BEncodable FileInfo where  fromBEncode = fromDict $ do  FileInfo <$>! "length"  <*>? "md5sum"  <*>! "path"  <*>? "tags" The reqKey7 is used to extract required key  if lookup is failed ! then whole destructuring fail. BNOTE: the actions SHOULD be sorted lexicographically by keys, so:  length < md5sum < path < tags. Assoc5 used to easily build dictionaries with required and A 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 BEncode FileInfo, though we don't want  to check the both maybes$ manually. The more declarative and  convenient way to define the ! method is to use  dictionary builders:  ! instance BEncode FileInfo where & toBEncode FileInfo {..} = toDict $  "length" .=! fileLength  .: "md5sum" .=? fileMD5sum  .: "path" .=! filePath  .: "tags" .=? fileTags  .: endDict >NOTE: the list of pairs SHOULD be sorted lexicographically by  keys, so: length < md5sum < path < tags. @This class is used to define new datatypes that could be easily " serialized using bencode format.  By default  ( have a generic implementation; suppose  the following datatype:   data List a = C { _head :: a ) , __tail :: List a }  | N  deriving Generic  If we don'/t need to obey any particular specification or A standard, the default instance could be derived automatically  from the > instance:  ( instance BEncode a => BEncode (List a) Example of derived ! result:   > toBEncode (C 123 $ C 1 N) < BDict (fromList [("head",BInteger 123),("tail",BList [])])  Note that '_'4 prefixes are omitted since they are used for lens. !&See an example of implementation here  "&See an example of implementation here . #$Result used in decoding operations. $?Typically used to throw an decoding error in fromBEncode; when ( BEncode value to match expected value. %Make required key value pair. &?Like (.=!) but if the value is not present then the key do not ) appear in resulting bencode dictionary. ' Cons a key/ value pair. (2Make a bencode value from dictionary description. )'Used to specify end of dictionary. See . *0Get lexicographical successor of the current key/ value pair. +Extract required value from the given key. ,+Extract optional value from the given key. -3Reconstruct a bencodable value from bencode value. .Shorthand for f <$> field (req k). /Shorthand for f <$> optional (field (req k)). 0Shorthand for f <*> field (req k). 1Shorthand for f <*> optional (field (req k)). 2Run a  monad. 3Decode a value from a strict ? using bencode format. 4.Encode a value using bencode format to a lazy ?. B@ABCDEF !"#$GHIJ%&'()*+,-./01234KLMNOPQRSTUVWXYZ[\]^_`abcdefghij !"#$%&'()*+,-./01234 !"43%&')(#$2*+,-./01:@ACBDEF !"#$GHIJ%&'()*+,-./01234KLMNOPQRSTUVWXYZ[\]^_`abcdefghijk      !"#$%&'()*+,-./0123456789:;<=>?@6ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopbencoding-0.4.0.2Data.BEncode.BDictData.BEncode.TypesData.BEncode.Internal Data.BEncodeBDictMapNilConsBKeyempty singletonnullmemberlookupunionmap bifoldMap fromAscList toAscListBValueBDictBListBStringBInteger isIntegerisStringisListisDictbuildparse ppBEncodeGetAssocBEncode toBEncode fromBEncodeResult decodingError.=!.=?.:toDictendDictnextreqoptfield<$>!<$>?<*>!<*>?fromDictdecodeencodebase Data.Monoidmappend$fMonoidBDictMap$fFoldableBDictMap$fFunctorBDictMap$fNFDataBDictMap$fNFDataBValuebuilderparserppBS GHC.GenericsGenericbytestring-0.10.0.2Data.ByteString.Internal ByteStringrunGetNoneSome GBEncodablegtogfrom selRenamegfromM1StoBEncodeIntegralfromBEncodeIntegral$fBEncode(,,,,)$fBEncode(,,,) $fBEncode(,,) $fBEncode(,) $fBEncode()$fBEncodeVersion $fBEncode[] $fBEncodeText $fBEncodeBool $fBEncodeInt$fBEncodeInt64$fBEncodeInt32$fBEncodeInt16 $fBEncodeInt8 $fBEncodeWord$fBEncodeWord64$fBEncodeWord32$fBEncodeWord16$fBEncodeWord8$fBEncodeBDictMap$fBEncodeByteString$fBEncodeInteger$fBEncodeBValue$fGBEncodableM1e$fGBEncodableM1BValue$fGBEncodableM1[]$fGBEncodableM1BDictMap$fGBEncodable:+:e$fGBEncodable:*:BDictMap$fGBEncodable:*:[]$fGBEncodableU1e$fGBEncodableK1BValue