Minimal test code (bs.hs):
import qualified Data.Binary as B
import qualified Data.ByteString.Lazy.Char8 as BSLC
main = do
BSLC.putStr $ B.encode $ Pad $ BSLC.pack "xxx"
data Pad = Pad BSLC.ByteString
instance B.Binary Pad where
put (Pad p) = do
B.put p
get = do
p <- B.get
return $ Pad p
And I get:
% runghc bs.hs | od -c
0000000 \0 \0 \0 \0 \0 \0 \0 003 x x x
0000013
% ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.10.2
I expect to get "xxx". I have no idea how the first 8 bytes (7 x \0 + 1 x 003) come from.