Commits

FlorianHartwig committed fe1fecb

Do encoding of Int and Integer values properly

  • Participants
  • Parent commits fc86e27

Comments (0)

Files changed (1)

src/Data/AttoBencode/Encode.hs

 
 import Data.AttoBencode.Types
 import Blaze.ByteString.Builder
-import Blaze.ByteString.Builder.Char.Utf8 (fromShow)
+import Blaze.Text.Int (integral)
 import Data.Map (toAscList)
 import Data.Monoid
 import qualified Data.ByteString.Char8 as B
 fromBValue (BString s) = fromString s
 fromBValue (BList l)   = fromWord8 lWord <> (mconcat . map fromBValue) l <> fromWord8 eWord
 fromBValue (BDict d)   = fromWord8 dWord <> (mconcat . map fromPair) (toAscList d) <> fromWord8 eWord
-fromBValue (BInt n)    = fromWord8 iWord <> fromShow n <> fromWord8 eWord
+fromBValue (BInt n)    = fromWord8 iWord <> integral n <> fromWord8 eWord
 
 fromString :: B.ByteString -> Builder
-fromString s = fromShow (B.length s) <> fromWord8 colon <> fromByteString s
+fromString s = integral (B.length s) <> fromWord8 colon <> fromByteString s
 {-# INLINE fromString #-}
 
 fromPair :: (B.ByteString, BValue) -> Builder