大きめのバイナリファイルをちょっとずつ処理する方法
を、ここんとこしばらく考えていたんですけど、こんなかんじですかねー?
import Data.ByteString (ByteString, hGet) import System.IO (Handle) data NextAct = Finish | Next (ByteString -> IO NextAct) Int procBinFile :: (ByteString -> IO NextAct) -> Int -> Handle -> IO () procBinFile action n hdl = do bs <- hGet hdl n next <- action bs case next of Finish -> return () Next act size -> procBinFile act size hdl