HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Moduleserialise-0.2.6.1Haskell2010

Codec.Serialise

This module provides functions to serialise and deserialise Haskell values for storage or transmission, to and from lazy ByteStrings. It also provides a type class and utilities to help you make your types serialisable.

For a full tutorial on using this module, see Codec.Serialise.Tutorial.

  • 2 types
  • 1 class
  • 8 values
  • Packageserialise-0.2.6.1
  • Exports11
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceSerialise.hs

High level, one-shot API

3 declarations

The following API exposes a high level interface allowing you to quickly convert between arbitrary Haskell values (which are an instance of Serialise) and lazy ByteStrings.

valueserialise :: Serialise a => a -> ByteString
#

Serialise a Haskell value to an external binary representation.

The output is represented as a lazy ByteString and is constructed incrementally.

valuedeserialise :: Serialise a => ByteString -> a
#

Deserialise a Haskell value from the external binary representation (which must have been made using serialise or related function).

Throws: DeserialiseFailure if the given external representation is invalid or does not correspond to a value of the expected type.

Deserialisation exceptions

1 declaration
datadata DeserialiseFailure
#

An exception type that may be returned (by pure functions) or thrown (by IO actions) that fail to deserialise a given input.

Instances4Eq, Show, Exception, NFData

Incremental encoding interface

3 declarations

The following API allows you to encode or decode CBOR values incrementally, which is useful for large structures that require you to stream values in over time.

valueserialiseIncremental :: Serialise a => a -> Builder
#

Serialise a Haskell value to an external binary representation.

The output is represented as a Builder and is constructed incrementally. The representation as a Builder allows efficient concatenation with other data.

valuedeserialiseIncremental :: Serialise a => ST s (IDecode s a)
#

Deserialise a Haskell value from the external binary representation.

This allows input data to be provided incrementally, rather than all in one go. It also gives an explicit representation of deserialisation errors.

Note that the incremental behaviour is only for the input data, not the output value: the final deserialised value is constructed and returned as a whole, not incrementally.

datadata IDecode s a
#

An Incremental decoder, used to represent the result of attempting to run a decoder over a given input, and return a value of type a.

Constructors

The Serialise class

1 declaration
classclass Serialise a where
#

Types that are instances of the Serialise class allow values to be quickly encoded or decoded directly to a CBOR representation, for object transmission or storage.

Methods

Instances114Serialise, …

IO operations

0 declarations

Convenient utilities for basic IO operations.

FilePath API

Handle API