From 122568b165498aeeff6e3d62a7d0d0c0728b5729 Mon Sep 17 00:00:00 2001 From: Sam Truzjan Date: Sun, 29 Sep 2013 08:54:05 +0400 Subject: Move rarely used predicated to Types module --- src/Data/BEncode.hs | 33 --------------------------------- 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 , optKey , (>--) , (>--?) - - -- * Predicates - , isInteger - , isString - , isList - , isDict ) where @@ -657,33 +651,6 @@ optKey d key (>--?) = optKey {-# INLINE (>--?) #-} -{-------------------------------------------------------------------- - Predicates ---------------------------------------------------------------------} - --- | Test if bencoded value is an integer. -isInteger :: BValue -> Bool -isInteger (BInteger _) = True -isInteger _ = False -{-# INLINE isInteger #-} - --- | Test if bencoded value is a string, both raw and utf8 encoded. -isString :: BValue -> Bool -isString (BString _) = True -isString _ = False -{-# INLINE isString #-} - --- | Test if bencoded value is a list. -isList :: BValue -> Bool -isList (BList _) = True -isList _ = False -{-# INLINE isList #-} - --- | Test if bencoded value is a dictionary. -isDict :: BValue -> Bool -isDict (BList _) = True -isDict _ = False -{-# INLINE isDict #-} {-------------------------------------------------------------------- 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 @@ -- Types for working with bencode data. -- module Data.BEncode.Types - ( BInteger + ( -- * Types + BInteger , BString , BList , BDict , BValue (..) + + -- * Predicates + , isInteger + , isString + , isList + , isDict ) where import Control.DeepSeq @@ -49,3 +56,31 @@ instance NFData BValue where rnf (BString s) = rnf s rnf (BList l) = rnf l rnf (BDict d) = rnf d + +{-------------------------------------------------------------------- + Predicates +--------------------------------------------------------------------} + +-- | Test if bencoded value is an integer. +isInteger :: BValue -> Bool +isInteger (BInteger _) = True +isInteger _ = False +{-# INLINE isInteger #-} + +-- | Test if bencoded value is a string, both raw and utf8 encoded. +isString :: BValue -> Bool +isString (BString _) = True +isString _ = False +{-# INLINE isString #-} + +-- | Test if bencoded value is a list. +isList :: BValue -> Bool +isList (BList _) = True +isList _ = False +{-# INLINE isList #-} + +-- | Test if bencoded value is a dictionary. +isDict :: BValue -> Bool +isDict (BList _) = True +isDict _ = False +{-# INLINE isDict #-} -- cgit v1.2.3