diff options
-rw-r--r-- | bench/Main.hs | 10 | ||||
-rw-r--r-- | bencoding.cabal | 4 | ||||
-rw-r--r-- | src/Data/BEncode.hs | 7 |
3 files changed, 11 insertions, 10 deletions
diff --git a/bench/Main.hs b/bench/Main.hs index 2edf43a..20de179 100644 --- a/bench/Main.hs +++ b/bench/Main.hs | |||
@@ -15,7 +15,6 @@ import Data.AttoBencode as B | |||
15 | import Data.AttoBencode.Parser as B | 15 | import Data.AttoBencode.Parser as B |
16 | import "bencoding" Data.BEncode as C | 16 | import "bencoding" Data.BEncode as C |
17 | 17 | ||
18 | |||
19 | instance NFData A.BEncode where | 18 | instance NFData A.BEncode where |
20 | rnf (A.BInt i) = rnf i | 19 | rnf (A.BInt i) = rnf i |
21 | rnf (A.BString s) = rnf s | 20 | rnf (A.BString s) = rnf s |
@@ -28,15 +27,8 @@ instance NFData B.BValue where | |||
28 | rnf (B.BList l) = rnf l | 27 | rnf (B.BList l) = rnf l |
29 | rnf (B.BDict d) = rnf d | 28 | rnf (B.BDict d) = rnf d |
30 | 29 | ||
31 | instance NFData C.BEncode where | ||
32 | rnf (C.BInteger i) = rnf i | ||
33 | rnf (C.BString s) = rnf s | ||
34 | rnf (C.BList l) = rnf l | ||
35 | rnf (C.BDict d) = rnf d | ||
36 | |||
37 | getRight :: Either String a -> a | 30 | getRight :: Either String a -> a |
38 | getRight (Left e) = error e | 31 | getRight = either error id |
39 | getRight (Right x) = x | ||
40 | 32 | ||
41 | main :: IO () | 33 | main :: IO () |
42 | main = do | 34 | main = do |
diff --git a/bencoding.cabal b/bencoding.cabal index 7918508..0aa251a 100644 --- a/bencoding.cabal +++ b/bencoding.cabal | |||
@@ -20,7 +20,8 @@ description: | |||
20 | * /0.1.0.0:/ Initial version. | 20 | * /0.1.0.0:/ Initial version. |
21 | 21 | ||
22 | 22 | ||
23 | extra-source-files: README.md .travis.yml | 23 | extra-source-files: README.md |
24 | .travis.yml | ||
24 | 25 | ||
25 | source-repository head | 26 | source-repository head |
26 | type: git | 27 | type: git |
@@ -30,6 +31,7 @@ source-repository head | |||
30 | library | 31 | library |
31 | exposed-modules: Data.BEncode | 32 | exposed-modules: Data.BEncode |
32 | build-depends: base == 4.* | 33 | build-depends: base == 4.* |
34 | , deepseq == 1.3.* | ||
33 | , containers >= 0.4 | 35 | , containers >= 0.4 |
34 | , bytestring >= 0.10.0.0 | 36 | , bytestring >= 0.10.0.0 |
35 | , attoparsec >= 0.10 | 37 | , attoparsec >= 0.10 |
diff --git a/src/Data/BEncode.hs b/src/Data/BEncode.hs index 62188ff..b53f6e5 100644 --- a/src/Data/BEncode.hs +++ b/src/Data/BEncode.hs | |||
@@ -102,6 +102,7 @@ module Data.BEncode | |||
102 | 102 | ||
103 | 103 | ||
104 | import Control.Applicative | 104 | import Control.Applicative |
105 | import Control.DeepSeq | ||
105 | import Control.Monad | 106 | import Control.Monad |
106 | import Data.Int | 107 | import Data.Int |
107 | import Data.Maybe (mapMaybe) | 108 | import Data.Maybe (mapMaybe) |
@@ -146,6 +147,12 @@ data BEncode = BInteger {-# UNPACK #-} !Int64 | |||
146 | | BDict Dict | 147 | | BDict Dict |
147 | deriving (Show, Read, Eq, Ord) | 148 | deriving (Show, Read, Eq, Ord) |
148 | 149 | ||
150 | instance NFData BEncode where | ||
151 | rnf (BInteger i) = rnf i | ||
152 | rnf (BString s) = rnf s | ||
153 | rnf (BList l) = rnf l | ||
154 | rnf (BDict d) = rnf d | ||
155 | |||
149 | -- | Result used in decoding operations. | 156 | -- | Result used in decoding operations. |
150 | type Result = Either String | 157 | type Result = Either String |
151 | 158 | ||