pipes-cborg-0.1: Encode and decode cborg streams using the pipes and cborg libraries.

Safe HaskellNone
LanguageHaskell98

Pipes.CBOR

Contents

Description

pipes utilities for encoding and decoding values as byte streams in CBOR format using the cborg library.

Synopsis

Encoding

serialise Source #

Arguments

:: (Serialise x, Monad m) 
=> x 
-> Producer' ByteString m () 

Renders x to a byte stream using its Serialise instance.

encode Source #

Arguments

:: Monad m 
=> Encoding 
-> Producer' ByteString m () 

Renders an Encoding to a byte stream.

Decoding

deserialise Source #

Parses x from a byte stream using its Serialise instance.

Also returns the number of bytes consumed in order to to decode the value.

Implementation note: No, ideally this function shouldn't run in IO. But unfortunately, the underlying deserialiseIncremental and its use of ST, which becomes both covariant and contravariant in Parser, make removing the IO tricky. The only IO this function performs is stToIO.

decode Source #

Arguments

:: MonadIO m 
=> (forall s. Decoder s x) 
-> Parser ByteString m (Either DeserialiseFailure (ByteOffset, x)) 

Parses @x“ from a byte stream using the given Decoder.

Also returns the number of bytes consumed in order to to decode the value.

Implementation note: No, ideally this function shouldn't run in IO. But unfortunately, the underlying deserialiseIncremental and its use of ST, which becomes both covariant and contravariant in Parser, make removing the IO tricky. The only IO this function performs is stToIO.