morley-1.19.0: Developer tools for the Michelson Language
Safe HaskellSafe-Inferred
LanguageHaskell2010

Morley.Util.Binary

Description

This module contains helper functions to deal with encoding and decoding of binary data.

Synopsis

Documentation

newtype UnpackError Source #

Any decoding error.

Constructors

UnpackError 

Fields

type TaggedDecoder a = TaggedDecoderM IdentityT a Source #

Specialization of TaggedDecoderM to IdentityT transformer.

data TaggedDecoderM t a Source #

Describes how decodeWithTagM should decode tag-dependent data. We expect bytes of such structure: tdTag followed by a bytestring which will be parsed with tdDecoder.

Constructors

TaggedDecoder 

Fields

(#:) :: Word8 -> Get a -> TaggedDecoder a infixr 0 Source #

Alias for TaggedDecoder constructor specialized to Get

(##:) :: Word8 -> t Get a -> TaggedDecoderM t a infixr 0 Source #

Alias for TaggedDecoder constructor.

decodeWithTag :: String -> [TaggedDecoder a] -> Get a Source #

Common decoder for the case when packed data starts with a tag (1 byte) that specifies how to decode remaining data.

This is a version of decodeWithTagM specialized to naked Get monad.

decodeWithTagM :: (MonadTrans t, Monad (t Get)) => String -> (Word8 -> t Get a) -> [TaggedDecoderM t a] -> t Get a Source #

Common decoder for the case when packed data starts with a tag (1 byte) that specifies how to decode remaining data.

This is a general version of decodeWithTag that allows Get to be wrapped in a monad transformer.

getByteStringCopy :: Int -> Get ByteString Source #

Get a bytestring of the given length leaving no references to the original data in serialized form.

getRemainingByteStringCopy :: Get ByteString Source #

Get remaining available bytes.

Note that reading all remaining decoded input may be expensive and is thus discouraged, use can use this function only when you know that amount of data to be consumed is limited, e.g. within decodeBytesLike call.

unknownTag :: String -> Word8 -> Get a Source #

Fail with "unknown tag" error.