summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSam Truzjan <pxqr.sta@gmail.com>2013-09-29 08:37:41 +0400
committerSam Truzjan <pxqr.sta@gmail.com>2013-09-29 08:37:41 +0400
commitaec496291de09c0387d51a3ee1fbdb5927b19c15 (patch)
tree85895e2182431b97cac41fe221798d93c63ffec9 /src
parentbb73c6aa23a05ad55432b869649c89e9eb656d6c (diff)
Rename decode and encode to mimic Binary package
This lead to more intuitive API.
Diffstat (limited to 'src')
-rw-r--r--src/Data/BEncode.hs10
-rw-r--r--src/Data/BEncode/Internal.hs12
2 files changed, 10 insertions, 12 deletions
diff --git a/src/Data/BEncode.hs b/src/Data/BEncode.hs
index 1969595..8dc7c89 100644
--- a/src/Data/BEncode.hs
+++ b/src/Data/BEncode.hs
@@ -73,8 +73,6 @@ module Data.BEncode
73 -- * Serialization 73 -- * Serialization
74 , encode 74 , encode
75 , decode 75 , decode
76 , encoded
77 , decoded
78 76
79 -- ** Dictionaries 77 -- ** Dictionaries
80 -- *** Building 78 -- *** Building
@@ -700,9 +698,9 @@ isDict _ = False
700--------------------------------------------------------------------} 698--------------------------------------------------------------------}
701 699
702-- | The same as 'decode' but returns any bencodable value. 700-- | The same as 'decode' but returns any bencodable value.
703decoded :: BEncode a => ByteString -> Result a 701decode :: BEncode a => ByteString -> Result a
704decoded = decode >=> fromBEncode 702decode = parse >=> fromBEncode
705 703
706-- | The same as 'encode' but takes any bencodable value. 704-- | The same as 'encode' but takes any bencodable value.
707encoded :: BEncode a => a -> Lazy.ByteString 705encode :: BEncode a => a -> Lazy.ByteString
708encoded = encode . toBEncode 706encode = build . toBEncode
diff --git a/src/Data/BEncode/Internal.hs b/src/Data/BEncode/Internal.hs
index 30cfbe7..3552bc9 100644
--- a/src/Data/BEncode/Internal.hs
+++ b/src/Data/BEncode/Internal.hs
@@ -9,8 +9,8 @@
9-- don't need to import this module. 9-- don't need to import this module.
10-- 10--
11module Data.BEncode.Internal 11module Data.BEncode.Internal
12 ( decode 12 ( parse
13 , encode 13 , build
14 , ppBEncode 14 , ppBEncode
15 ) where 15 ) where
16 16
@@ -59,8 +59,8 @@ builder = go
59 59
60-- | Convert bencoded value to raw bytestring according to the 60-- | Convert bencoded value to raw bytestring according to the
61-- specification. 61-- specification.
62encode :: BValue -> Lazy.ByteString 62build :: BValue -> Lazy.ByteString
63encode = B.toLazyByteString . builder 63build = B.toLazyByteString . builder
64 64
65{-------------------------------------------------------------------- 65{--------------------------------------------------------------------
66-- Deserialization 66-- Deserialization
@@ -113,8 +113,8 @@ parser = valueP
113 113
114-- | Try to convert raw bytestring to bencoded value according to 114-- | Try to convert raw bytestring to bencoded value according to
115-- specification. 115-- specification.
116decode :: ByteString -> Either String BValue 116parse :: ByteString -> Either String BValue
117decode = P.parseOnly parser 117parse = P.parseOnly parser
118 118
119{-------------------------------------------------------------------- 119{--------------------------------------------------------------------
120 Pretty Printing 120 Pretty Printing