From 2e19d4347e5a3d4a0306bc4ffff0a0cafcdbb2be Mon Sep 17 00:00:00 2001 From: Sam Truzjan Date: Mon, 30 Sep 2013 07:02:10 +0400 Subject: Update documentation --- src/Data/BEncode.hs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Data/BEncode.hs b/src/Data/BEncode.hs index d70cad4..8580d40 100644 --- a/src/Data/BEncode.hs +++ b/src/Data/BEncode.hs @@ -121,26 +121,26 @@ type Result = Either String -- | This class is used to define new datatypes that could be easily -- serialized using bencode format. -- --- By default 'BEncodable' have a generic implementation; suppose +-- By default 'BEncode' have a generic implementation; suppose -- the following datatype: -- --- > data List a = Cons { _head :: a --- > , __tail :: (List a) } --- > | Nil +-- > data List a = C { _head :: a +-- > , __tail :: List a } +-- > | N -- > deriving Generic -- -- If we don't need to obey any particular specification or -- standard, the default instance could be derived automatically -- from the 'Generic' instance: -- --- > instance BEncodable a => BEncodable (List a) +-- > instance BEncode a => BEncode (List a) -- -- Example of derived 'toBEncode' result: -- --- > > toBEncode (Cons 123 $ Cons 1 Nil) +-- > > toBEncode (C 123 $ C 1 N) -- > BDict (fromList [("head",BInteger 123),("tail",BList [])]) -- --- Note that '_' prefixes are omitted. +-- Note that '_' prefixes are omitted since they are used for lens. -- class BEncode a where -- | See an example of implementation here 'Assoc' @@ -155,7 +155,7 @@ class BEncode a where toBEncode = gto . from #endif - -- | See an example of implementation here 'reqKey'. + -- | See an example of implementation here 'Get'. fromBEncode :: BValue -> Result a #if __GLASGOW_HASKELL__ >= 702 @@ -700,10 +700,10 @@ fromDict _ _ = decodingError (show (typeOf inst)) Encoding --------------------------------------------------------------------} --- | The same as 'decode' but returns any bencodable value. +-- | Decode a value from a strict 'ByteString' using bencode format. decode :: BEncode a => ByteString -> Result a decode = parse >=> fromBEncode --- | The same as 'encode' but takes any bencodable value. +-- | Encode a value using bencode format to a lazy 'ByteString'. encode :: BEncode a => a -> Lazy.ByteString encode = build . toBEncode -- cgit v1.2.3