summaryrefslogtreecommitdiff
path: root/src/Data/BEncode/Types.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Data/BEncode/Types.hs')
-rw-r--r--src/Data/BEncode/Types.hs37
1 files changed, 36 insertions, 1 deletions
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--
10module Data.BEncode.Types 10module 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
18import Control.DeepSeq 25import 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.
65isInteger :: BValue -> Bool
66isInteger (BInteger _) = True
67isInteger _ = False
68{-# INLINE isInteger #-}
69
70-- | Test if bencoded value is a string, both raw and utf8 encoded.
71isString :: BValue -> Bool
72isString (BString _) = True
73isString _ = False
74{-# INLINE isString #-}
75
76-- | Test if bencoded value is a list.
77isList :: BValue -> Bool
78isList (BList _) = True
79isList _ = False
80{-# INLINE isList #-}
81
82-- | Test if bencoded value is a dictionary.
83isDict :: BValue -> Bool
84isDict (BList _) = True
85isDict _ = False
86{-# INLINE isDict #-}