diff options
author | Sam Truzjan <pxqr.sta@gmail.com> | 2013-09-29 08:54:05 +0400 |
---|---|---|
committer | Sam Truzjan <pxqr.sta@gmail.com> | 2013-09-29 08:54:05 +0400 |
commit | 122568b165498aeeff6e3d62a7d0d0c0728b5729 (patch) | |
tree | 2b5afec3713ff47c6bae280097cd8438c9b64cd5 | |
parent | 1e2f12b25b7053a48e2af2d28c05191282014484 (diff) |
Move rarely used predicated to Types module
-rw-r--r-- | src/Data/BEncode.hs | 33 | ||||
-rw-r--r-- | src/Data/BEncode/Types.hs | 37 |
2 files changed, 36 insertions, 34 deletions
diff --git a/src/Data/BEncode.hs b/src/Data/BEncode.hs index 16a6160..353d66e 100644 --- a/src/Data/BEncode.hs +++ b/src/Data/BEncode.hs | |||
@@ -88,12 +88,6 @@ module Data.BEncode | |||
88 | , optKey | 88 | , optKey |
89 | , (>--) | 89 | , (>--) |
90 | , (>--?) | 90 | , (>--?) |
91 | |||
92 | -- * Predicates | ||
93 | , isInteger | ||
94 | , isString | ||
95 | , isList | ||
96 | , isDict | ||
97 | ) where | 91 | ) where |
98 | 92 | ||
99 | 93 | ||
@@ -657,33 +651,6 @@ optKey d key | |||
657 | (>--?) = optKey | 651 | (>--?) = optKey |
658 | {-# INLINE (>--?) #-} | 652 | {-# INLINE (>--?) #-} |
659 | 653 | ||
660 | {-------------------------------------------------------------------- | ||
661 | Predicates | ||
662 | --------------------------------------------------------------------} | ||
663 | |||
664 | -- | Test if bencoded value is an integer. | ||
665 | isInteger :: BValue -> Bool | ||
666 | isInteger (BInteger _) = True | ||
667 | isInteger _ = False | ||
668 | {-# INLINE isInteger #-} | ||
669 | |||
670 | -- | Test if bencoded value is a string, both raw and utf8 encoded. | ||
671 | isString :: BValue -> Bool | ||
672 | isString (BString _) = True | ||
673 | isString _ = False | ||
674 | {-# INLINE isString #-} | ||
675 | |||
676 | -- | Test if bencoded value is a list. | ||
677 | isList :: BValue -> Bool | ||
678 | isList (BList _) = True | ||
679 | isList _ = False | ||
680 | {-# INLINE isList #-} | ||
681 | |||
682 | -- | Test if bencoded value is a dictionary. | ||
683 | isDict :: BValue -> Bool | ||
684 | isDict (BList _) = True | ||
685 | isDict _ = False | ||
686 | {-# INLINE isDict #-} | ||
687 | 654 | ||
688 | {-------------------------------------------------------------------- | 655 | {-------------------------------------------------------------------- |
689 | Encoding | 656 | Encoding |
diff --git a/src/Data/BEncode/Types.hs b/src/Data/BEncode/Types.hs index fae90fe..15f570f 100644 --- a/src/Data/BEncode/Types.hs +++ b/src/Data/BEncode/Types.hs | |||
@@ -8,11 +8,18 @@ | |||
8 | -- Types for working with bencode data. | 8 | -- Types for working with bencode data. |
9 | -- | 9 | -- |
10 | module Data.BEncode.Types | 10 | module Data.BEncode.Types |
11 | ( BInteger | 11 | ( -- * Types |
12 | BInteger | ||
12 | , BString | 13 | , BString |
13 | , BList | 14 | , BList |
14 | , BDict | 15 | , BDict |
15 | , BValue (..) | 16 | , BValue (..) |
17 | |||
18 | -- * Predicates | ||
19 | , isInteger | ||
20 | , isString | ||
21 | , isList | ||
22 | , isDict | ||
16 | ) where | 23 | ) where |
17 | 24 | ||
18 | import Control.DeepSeq | 25 | import Control.DeepSeq |
@@ -49,3 +56,31 @@ instance NFData BValue where | |||
49 | rnf (BString s) = rnf s | 56 | rnf (BString s) = rnf s |
50 | rnf (BList l) = rnf l | 57 | rnf (BList l) = rnf l |
51 | rnf (BDict d) = rnf d | 58 | rnf (BDict d) = rnf d |
59 | |||
60 | {-------------------------------------------------------------------- | ||
61 | Predicates | ||
62 | --------------------------------------------------------------------} | ||
63 | |||
64 | -- | Test if bencoded value is an integer. | ||
65 | isInteger :: BValue -> Bool | ||
66 | isInteger (BInteger _) = True | ||
67 | isInteger _ = False | ||
68 | {-# INLINE isInteger #-} | ||
69 | |||
70 | -- | Test if bencoded value is a string, both raw and utf8 encoded. | ||
71 | isString :: BValue -> Bool | ||
72 | isString (BString _) = True | ||
73 | isString _ = False | ||
74 | {-# INLINE isString #-} | ||
75 | |||
76 | -- | Test if bencoded value is a list. | ||
77 | isList :: BValue -> Bool | ||
78 | isList (BList _) = True | ||
79 | isList _ = False | ||
80 | {-# INLINE isList #-} | ||
81 | |||
82 | -- | Test if bencoded value is a dictionary. | ||
83 | isDict :: BValue -> Bool | ||
84 | isDict (BList _) = True | ||
85 | isDict _ = False | ||
86 | {-# INLINE isDict #-} | ||