foldLogFile :: Binary act => (act -> a -> IO a) -> a -> B.ByteString -> IO a
foldLogFile processAction initial = go initial
    where
      go x bs | B.null bs = return x
      go x bs = uncurry go =<< (step x bs `catch` \_ -> return (x, B.drop 1 bs))

      step x bs = do
        let (act, bs', _) = runGetState get bs 0
        x' <- processAction act x
        return (x', bs')
foldLogFile :: Binary act => (act -> a -> IO a) -> a -> B.ByteString -> IO a
foldLogFile processAction initial = go initial
    where
      go x bs | B.null bs = return x
      go x bs = uncurry go =<< (step x bs `catch` \_ -> return (x, B.drop 1 bs))

      step x bs = do
        let (act, bs', _) = runGetState get bs 0
        x' <- processAction act x
        return (x', bs')
foldLogFile processAction initial = go initial
    where
      go x bs | B.null bs = return x
      go x bs = uncurry go =<< (step x bs `catch` \_ -> return (x, B.drop 1 bs))

      step x bs = do
        let (act, bs', _) = runGetState get bs 0
        x' <- processAction act x
        return (x', bs')