diff options
author | Sam Truzjan <pxqr.sta@gmail.com> | 2013-09-30 07:02:10 +0400 |
---|---|---|
committer | Sam Truzjan <pxqr.sta@gmail.com> | 2013-09-30 07:02:10 +0400 |
commit | 2e19d4347e5a3d4a0306bc4ffff0a0cafcdbb2be (patch) | |
tree | d18b1279a5992acdd761553273d7ccba5c217106 | |
parent | edc81ffee27e489453cbd599f9ec95a3071ddb5a (diff) |
Update documentation
-rw-r--r-- | src/Data/BEncode.hs | 20 |
1 files 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 | |||
121 | -- | This class is used to define new datatypes that could be easily | 121 | -- | This class is used to define new datatypes that could be easily |
122 | -- serialized using bencode format. | 122 | -- serialized using bencode format. |
123 | -- | 123 | -- |
124 | -- By default 'BEncodable' have a generic implementation; suppose | 124 | -- By default 'BEncode' have a generic implementation; suppose |
125 | -- the following datatype: | 125 | -- the following datatype: |
126 | -- | 126 | -- |
127 | -- > data List a = Cons { _head :: a | 127 | -- > data List a = C { _head :: a |
128 | -- > , __tail :: (List a) } | 128 | -- > , __tail :: List a } |
129 | -- > | Nil | 129 | -- > | N |
130 | -- > deriving Generic | 130 | -- > deriving Generic |
131 | -- | 131 | -- |
132 | -- If we don't need to obey any particular specification or | 132 | -- If we don't need to obey any particular specification or |
133 | -- standard, the default instance could be derived automatically | 133 | -- standard, the default instance could be derived automatically |
134 | -- from the 'Generic' instance: | 134 | -- from the 'Generic' instance: |
135 | -- | 135 | -- |
136 | -- > instance BEncodable a => BEncodable (List a) | 136 | -- > instance BEncode a => BEncode (List a) |
137 | -- | 137 | -- |
138 | -- Example of derived 'toBEncode' result: | 138 | -- Example of derived 'toBEncode' result: |
139 | -- | 139 | -- |
140 | -- > > toBEncode (Cons 123 $ Cons 1 Nil) | 140 | -- > > toBEncode (C 123 $ C 1 N) |
141 | -- > BDict (fromList [("head",BInteger 123),("tail",BList [])]) | 141 | -- > BDict (fromList [("head",BInteger 123),("tail",BList [])]) |
142 | -- | 142 | -- |
143 | -- Note that '_' prefixes are omitted. | 143 | -- Note that '_' prefixes are omitted since they are used for lens. |
144 | -- | 144 | -- |
145 | class BEncode a where | 145 | class BEncode a where |
146 | -- | See an example of implementation here 'Assoc' | 146 | -- | See an example of implementation here 'Assoc' |
@@ -155,7 +155,7 @@ class BEncode a where | |||
155 | toBEncode = gto . from | 155 | toBEncode = gto . from |
156 | #endif | 156 | #endif |
157 | 157 | ||
158 | -- | See an example of implementation here 'reqKey'. | 158 | -- | See an example of implementation here 'Get'. |
159 | fromBEncode :: BValue -> Result a | 159 | fromBEncode :: BValue -> Result a |
160 | 160 | ||
161 | #if __GLASGOW_HASKELL__ >= 702 | 161 | #if __GLASGOW_HASKELL__ >= 702 |
@@ -700,10 +700,10 @@ fromDict _ _ = decodingError (show (typeOf inst)) | |||
700 | Encoding | 700 | Encoding |
701 | --------------------------------------------------------------------} | 701 | --------------------------------------------------------------------} |
702 | 702 | ||
703 | -- | The same as 'decode' but returns any bencodable value. | 703 | -- | Decode a value from a strict 'ByteString' using bencode format. |
704 | decode :: BEncode a => ByteString -> Result a | 704 | decode :: BEncode a => ByteString -> Result a |
705 | decode = parse >=> fromBEncode | 705 | decode = parse >=> fromBEncode |
706 | 706 | ||
707 | -- | The same as 'encode' but takes any bencodable value. | 707 | -- | Encode a value using bencode format to a lazy 'ByteString'. |
708 | encode :: BEncode a => a -> Lazy.ByteString | 708 | encode :: BEncode a => a -> Lazy.ByteString |
709 | encode = build . toBEncode | 709 | encode = build . toBEncode |