úÎC>ó#      !"portablestablepxqr.sta@gmail.com TrustworthyAssoc5 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 BEncodable 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 BEncodable FileInfo where ( toBEncode FileInfo {..} = fromAssocs  [ "length" --> fileLength  , "md5sum" -->? fileMD5sum  , "path" --> filePath  , "tags" -->? fileTags  ]  ... @This class is used to define new datatypes that could be easily " serialized using bencode format.  By default  BEncodable( have a generic implementation; suppose  the following datatype:  " data List a = Cons { _head :: a + , __tail :: (List a) }  | Nil  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 BEncodable a => BEncodable (List a) Example of derived  result:  % > toBEncode (Cons 123 $ Cons 1 Nil) < BDict (fromList [("head",BInteger 123),("tail",BList [])])  Note that '_' prefixes are omitted. &See an example of implementation here  &See an example of implementation here . $Result used in decoding operations. 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; ?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 bencoded dictionary. 9Build BEncode dictionary using key -> value description. A faster version of  . Should be used only when keys * in builder list are sorted by ascending. BDictionary 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   looks like:  $ instance BEncodable FileInfo where  ...  fromBEncode (BDict d) = " FileInfo <$> d >-- "length" " <*> d >--? "md5sum"  <*> d >-- "path"  <*> d >--? "tags" , fromBEncode _ = decodingError "FileInfo" The reqKey7 is used to extract required key  if lookup is failed ! then whole destructuring fail. ;Used to extract optional key  if lookup is failed returns  $. Infix version of the . Infix version of the . &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. :Convert bencoded value to raw bytestring according to the  specification. =Try to convert raw bytestring to bencoded value according to  specification.  The same as # but returns any bencodable value.  The same as ! but takes any bencodable value. 3BEncode format encoder according to specification. !2BEncode format parser according to specification. "BConvert to easily readable JSON-like document. Typically used for  debugging purposes. O%&'() *+,- !."/0123456789:;<=>?@ABCDEFGHIJKLMNOP#  !"#  " !E%&'()  *+,- !."/0123456789:;<=>?@ABCDEFGHIJKLMNOPQ         !"#!$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQbencoding-0.3.0.0 Data.BEncodeAssocBEncode toBEncode fromBEncodeResultBValueBDictBListBStringBIntegerBKey decodingError-->-->? fromAssocs fromAscAssocsreqKeyoptKey>-->--? isIntegerisStringisListisDictencodedecodedecodedencodedbuilderparser ppBEncodebase GHC.GenericsGeneric Data.MaybeNothingunAssoc GBEncodablegtogfrom selRenamegfromM1StoBEncodeIntegralfromBEncodeIntegralppBS$fBEncode(,,,,)$fBEncode(,,,) $fBEncode(,,) $fBEncode(,) $fBEncode()$fBEncodeVersion $fBEncodeSet $fBEncodeMap $fBEncode[] $fBEncodeText $fBEncodeBool $fBEncodeInt$fBEncodeInt64$fBEncodeInt32$fBEncodeInt16 $fBEncodeInt8 $fBEncodeWord$fBEncodeWord64$fBEncodeWord32$fBEncodeWord16$fBEncodeWord8$fBEncodeByteString$fBEncodeInteger$fBEncodeBValue$fGBEncodableM1e$fGBEncodableM1BValue$fGBEncodableM1[]$fGBEncodableM1Map$fGBEncodable:+:e$fGBEncodable:*:Map$fGBEncodable:*:[]$fGBEncodableU1e$fGBEncodableK1BValue$fNFDataBValue