cereal-plus-0.3.3: An extended serialization library on top of "cereal"

Safe HaskellNone

CerealPlus.Deserialize

Description

A monad-transformer over Data.Serialize.Get.

Synopsis

Documentation

runPartial :: Deserialize m a -> ByteString -> m (Result m a)Source

Run on a chunk of data and get a partial result.

data Result m a Source

A partial result of deserialization.

Constructors

Fail Text ByteString

A message describing the deserialization failure and a remaining chunk.

Partial (ByteString -> m (Result m a))

A continuation function, which should be supplied with the next chunk.

Done a ByteString

A deserialized data structure and a remaining chunk.

liftGet :: Monad m => Get a -> Deserialize m aSource

Run a Get action of the "cereal" library.

mapBase :: (Monad m, Monad m') => (forall b. m b -> m' b) -> Deserialize m a -> Deserialize m' aSource

Change the base monad. Same as transMap of the "layers" library.

throwError :: Monad m => Text -> Deserialize m aSource

Fail with a message.

Since there's no consensus on how to implement catchError of MonadError, we'll go with just this function.

It is not implemented as fail because fail is pure evil.