me2*_*me2 3 haskell bytestring
试图使用Data.Binary.Get和ByteString而不了解发生了什么.我的代码如下:
getSegmentParams :: Get (Int, L.ByteString)
getSegmentParams = do
seglen <- liftM fromIntegral getWord16be
params <- getByteString (seglen - 2)
return (seglen, params)
Run Code Online (Sandbox Code Playgroud)
我对返回元组的第三项,即有效负载得到以下错误:
Couldn't match expected type `L.ByteString'
against inferred type `bytestring-0.9.1.4:Data.ByteString.Internal.ByteString'
Run Code Online (Sandbox Code Playgroud)
有人请向我解释Data.Binary.Get和ByteStrings之间的互动以及我如何做我想要的事情.谢谢.
它表示你期望元组的第二个元素是L.ByteString(我假设L来自Data.ByteString.Lazy),但getByteString例程返回一个严格的ByteString Data.ByteString.你可能想用getLazyByteString.