HORIZON HASKELLDocslts/ghc-9.14.xd82dee82026-10-12Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · d82dee8 · 2026-10-12

Modulecardano-binary-1.9.1.0

Cardano.Binary

  • 12 types
  • 2 classes
  • 152 values

Decode a string of bytes as a ByteArray.

Also note that this will eagerly copy the content out of the input to ensure that the input does not leak in the event that the ByteArray is live but not forced.

Attempt to decode a token for the length of a finite, known list, or an indefinite list. If Nothing is returned, then an indefinite length list occurs afterwords. If Just x is returned, then a list of length x is encoded.

Attempt to decode a token for the length of a finite, known map, or an indefinite map. If Nothing is returned, then an indefinite length map occurs afterwords. If Just x is returned, then a map of length x is encoded.

Decode a textual string as UTF-8 encoded ByteArray. Note that the result is not validated to be well-formed UTF-8.

Also note that this will eagerly copy the content out of the input to ensure that the input does not leak in the event that the ByteArray is live but not forced.

Decode canonical representation of a textual string as UTF-8 encoded ByteArray. Note that the result is not validated to be well-formed UTF-8.

Also note that this will eagerly copy the content out of the input to ensure that the input does not leak in the event that the ByteArray is live but not forced.

valuedecodeWordOf
  1. :: Word

    Expected value of the decoded word

  2. -> Decoder s ()
#

Attempt to decode a word with decodeWord, and ensure the word is exactly as expected, or fail.

valueliftST :: ST s a -> Decoder s a
#

Lift an ST action into a Decoder. Useful for, e.g., leveraging in-place mutation to efficiently build a deserialised value.

valuepeekAvailable :: Decoder s Int
#

Peek and return the length of the current buffer that we're running our decoder on.

Get the current ByteOffset in the input byte sequence of the Decoder.

The Decoder does not provide any facility to get at the input data directly (since that is tricky with an incremental decoder). The next best is this primitive which can be used to keep track of the offset within the input bytes that makes up the encoded form of a term.

By keeping track of the byte offsets before and after decoding a subterm (a pattern captured by decodeWithByteSpan) and if the overall input data is retained then this is enables later retrieving the span of bytes for the subterm.

valueencodeBreak :: Encoding
#

Encode a 'break', used to specify the end of indefinite length objects like maps or lists.

Encode a token specifying the beginning of a string of bytes of indefinite length. In reality, this specifies a stream of many occurrences of encodeBytes, each specifying a single chunk of the overall string. After all the bytes desired have been encoded, you should follow it with a break token (see encodeBreak).

valueencodeListLen :: Word -> Encoding
#

Encode the length of a list, used to indicate that the following tokens represent the list values.

Encode a token specifying that this is the beginning of an indefinite list of unknown size. Tokens representing the list are expected afterwords, followed by a break token (see encodeBreak) when the list has ended.

valueencodeMapLen :: Word -> Encoding
#

Encode the length of a Map, used to indicate that the following tokens represent the map values.

Encode a token specifying that this is the beginning of an indefinite map of unknown size. Tokens representing the map are expected afterwords, followed by a break token (see encodeBreak) when the map has ended.

Include pre-encoded valid CBOR data into the Encoding.

The data is included into the output as-is without any additional wrapper.

This should be used with care. The data must be a valid CBOR encoding, but this is not checked.

This is useful when you have CBOR data that you know is already valid, e.g. previously validated and stored on disk, and you wish to include it without having to decode and re-encode it.

valueencodeSimple :: Word8 -> Encoding
#

Encode a 'simple' CBOR token that can be represented with an 8-bit word. You probably don't ever need this.

datadata DecoderError
#
Instances5Eq, Show, Exception, NFData, Buildable
classclass Typeable a => FromCBOR a where
#

Methods

Instances44FromCBOR, …
datadata Case t
#

Constructors

Instances2Functor, Buildable
classclass Typeable a => ToCBOR a where
#

Methods

Instances46ToCBOR, …
typetype ByteOffset = Int64
#

A 0-based offset within the overall byte sequence that makes up the input to the Decoder.

This is an Int64 since Decoder is incremental and can decode more data than fits in memory at once. This is also compatible with the result type of length.

datadata DecodeAction s a
#

An action, representing a step for a decoder to taken and a continuation to invoke with the expected value.

Constructors

newtypenewtype Decoder s a
#

A continuation-based decoder, used for decoding values that were previously encoded using the Codec.CBOR.Encoding module. As Decoder has a Monad instance, you can easily write Decoders monadically for building your deserialisation logic.

Instances4Monad, Functor, MonadFail, Applicative
datadata TokenType
#
Instances5Bounded, Enum, Eq, Ord, Show
newtypenewtype Encoding
#

An intermediate form used during serialisation, specified as a Monoid. It supports efficient concatenation, and is equivalent to a specialised Endo Tokens type.

It is used for the stage in serialisation where we flatten out the Haskell data structure but it is independent of any specific external binary or text format.

Traditionally, to build any arbitrary Encoding value, you specify larger structures from smaller ones and append the small ones together using mconcat.

Constructors

Instances4Show, Semigroup, Monoid, ToCBOR
datadata Tokens
#
Instances3Eq, Show, ToCBOR
  • Eq TokensDefined in cborg-0.2.10.0 · Codec.CBOR.Encoding
  • Show TokensDefined in cborg-0.2.10.0 · Codec.CBOR.Encoding
  • ToCBOR (Tokens -> Tokens)Defined in cardano-binary-1.9.1.0 · Cardano.Binary.ToCBOR