]> git.rkrishnan.org Git - functorrent.git/commitdiff
Derive `show` automatically for BVal
authorJaseem Abid <jaseemabid@gmail.com>
Sat, 21 Feb 2015 13:01:33 +0000 (18:31 +0530)
committerJaseem Abid <jaseemabid@gmail.com>
Sat, 21 Feb 2015 13:01:33 +0000 (18:31 +0530)
src/Bencode.hs

index 717170ede68b353f1c1aa0dcb012bf4853b46fb0..873c1e1c9bacaca325819697fb3fff041adf33df 100644 (file)
@@ -8,21 +8,14 @@ import Text.ParserCombinators.Parsec
 import Control.Applicative ((<*))
 import Data.Functor
 
-data BVal =
-    Bint Integer
-  | Bstr BC.ByteString
-  | Blist [BVal]
-  | Bdict InfoDict
-  deriving (Ord, Eq)
+data BVal = Bint Integer
+          | Bstr BC.ByteString
+          | Blist [BVal]
+          | Bdict InfoDict
+            deriving (Ord, Eq, Show)
 
 type InfoDict = M.Map BVal BVal
 
-instance Show BVal where
-  show (Bint i) = show i
-  show (Bstr s) = "\"" ++ BC.unpack s ++ "\""
-  show (Blist xs) = show xs
-  show (Bdict m) = show m
-
 -- $setup
 -- >>> import Data.Either