Pcap字节字符串类型

时间:2015-05-03 17:07:39

标签: haskell

所以我试图一起使用管道和Network.Pcap但是我遇到了一个带有Data.ByteString类型和Network.Pcap字节串类型的bug。

{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
import Network.Pcap
import Pipes 

import Data.ByteString
--import Data.ByteString.Lazy

getPacket :: (MonadIO m) => PcapHandle -> Producer' (PktHdr, ByteString) m ()
getPacket handle = do
    x <- liftIO $ nextBS handle   
    yield x

main = return ()

正如你从注释中看到的那样,如果bytestring是懒惰的还是严格的,那不是问题,因为我试过了两个。这是错误:

PCAP.hs:12:15:
Couldn't match type `bytestring-0.10.0.2:Data.ByteString.Internal.ByteString'
              with `ByteString'
Expected type: (PktHdr, ByteString)
  Actual type: (PktHdr,
                bytestring-0.10.0.2:Data.ByteString.Internal.ByteString)
In the first argument of `yield', namely `x'
In a stmt of a 'do' block: yield x
In the expression:
  do { x <- liftIO $ nextBS handle;
       yield x }

我的bytestring类型有什么问题?

0 个答案:

没有答案