From: Jaseem Abid Date: Sat, 21 Feb 2015 13:01:33 +0000 (+0530) Subject: Derive `show` automatically for BVal X-Git-Url: https://git.rkrishnan.org/pf/quickstart.html?a=commitdiff_plain;h=f418f8175d3d6740c81f54f6051555c8c6e599b7;p=functorrent.git Derive `show` automatically for BVal --- 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