From f418f8175d3d6740c81f54f6051555c8c6e599b7 Mon Sep 17 00:00:00 2001 From: Jaseem Abid Date: Sat, 21 Feb 2015 18:31:33 +0530 Subject: [PATCH] Derive `show` automatically for BVal --- src/Bencode.hs | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/Bencode.hs b/src/Bencode.hs index 717170e..873c1e1 100644 --- a/src/Bencode.hs +++ b/src/Bencode.hs @@ -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 -- 2.37.2