streaming-binary-0.3.0.0: Streaming interface to binary.

Safe HaskellNone
LanguageHaskell2010

Streaming.Binary

Description

This module implements a method to ingest a sequence of Data.Binary encoded records using bounded memory. Minimal example:

{-# LANGUAGE TypeApplications #-}

import Data.Function ((&))
import qualified Data.ByteString.Streaming as Q
import Streaming
import Streaming.Binary
import qualified Streaming.Prelude as S

-- Interpret all bytes on stdin as a sequence of integers.
-- Print them on-the-fly on stdout.
main = Q.getContents & decoded @Int & S.print

Documentation

decode :: (Binary a, Monad m) => ByteString m r -> m (ByteString m r, Int64, Either String a) Source #

decoded :: (Binary a, Monad m) => ByteString m r -> Stream (Of a) m (ByteString m r, Int64, Either String r) Source #

encode :: (Binary a, MonadIO m) => a -> ByteString m () Source #

encodeWith :: MonadIO m => (a -> Put) -> a -> ByteString m () Source #

encoded :: (Binary a, MonadIO m) => Stream (Of a) IO () -> ByteString m () Source #

encodedWith :: MonadIO m => (a -> Put) -> Stream (Of a) IO () -> ByteString m () Source #