module Network.Loshadka.Message (pack) where import Prelude hiding (length) import Data.ByteString.Lazy.Char8 (ByteString, append, cons, length) import Data.Binary (encode) import Data.Int (Int8) pack :: ByteString -> ByteString pack m = packData $ cons '\NUL' (packData m) where packData d = append (packInt $ length d) d packInt i = encode (fromIntegral i :: Int8)