引き続き簡単だった、ほぼ頭使わないで使える。
conduit_binary.hs
{-# LANGUAGE OverloadedStrings #-}
import Control.Applicative
import Data.Binary.Get
import qualified Data.ByteString as BS
import Data.Conduit
import Data.Conduit.Serialization.Binary
import Data.Word
query :: BS.ByteString
query = "\64\64\0ABC"
qSource :: Monad m => Source m BS.ByteString
qSource = yield query
getter :: Get (Word8, Word16, BS.ByteString)
getter = (,,) <$> getWord8 <*> getWord16be <*> getByteString 3
main = do
result <- qSource $$ sinkGet getter
print result