| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Ouroboros.Consensus.Util.Versioned
Synopsis
- data Versioned a = Versioned {
- versionNumber :: !VersionNumber
- versioned :: !a
- data VersionNumber
- data VersionError
- data VersionDecoder a where
- Incompatible :: String -> VersionDecoder a
- Decode :: (forall s. Decoder s a) -> VersionDecoder a
- Migrate :: VersionDecoder from -> (from -> Either String to) -> VersionDecoder to
- encodeVersioned :: (a -> Encoding) -> Versioned a -> Encoding
- encodeVersion :: VersionNumber -> Encoding -> Encoding
- decodeVersioned :: [(VersionNumber, VersionDecoder a)] -> forall s. Decoder s (Versioned a)
- decodeVersion :: [(VersionNumber, VersionDecoder a)] -> forall s. Decoder s a
Documentation
Constructors
| Versioned | |
Fields
| |
data VersionNumber Source #
Instances
data VersionError Source #
Constructors
| IncompatibleVersion VersionNumber String | We cannot deserialise the version of the data with the given
For example, the given format lacks data that was added in later version that cannot be reconstructed from scratch. |
| UnknownVersion VersionNumber | The given |
| MigrationFailed VersionNumber String | A migration from the given |
Instances
| Show VersionError Source # | |
Defined in Ouroboros.Consensus.Util.Versioned Methods showsPrec :: Int -> VersionError -> ShowS # show :: VersionError -> String # showList :: [VersionError] -> ShowS # | |
| Exception VersionError Source # | |
Defined in Ouroboros.Consensus.Util.Versioned Methods toException :: VersionError -> SomeException # fromException :: SomeException -> Maybe VersionError # displayException :: VersionError -> String # | |
data VersionDecoder a where Source #
How to decode a version of a format.
Constructors
| Incompatible :: String -> VersionDecoder a | This version is incompatible, fail with |
| Decode :: (forall s. Decoder s a) -> VersionDecoder a | Decode the version using the given |
| Migrate :: VersionDecoder from -> (from -> Either String to) -> VersionDecoder to | Decode an other format ( |
encodeVersion :: VersionNumber -> Encoding -> Encoding Source #
Given a VersionNumber and the encoding of an a, encode the
corresponding . Use Versioned adecodeVersion to decode it.
decodeVersioned :: [(VersionNumber, VersionDecoder a)] -> forall s. Decoder s (Versioned a) Source #
decodeVersion :: [(VersionNumber, VersionDecoder a)] -> forall s. Decoder s a Source #
Decode a versioned a (encoded using encodeVersion or
encodeVersioned).
The corresponding VersionDecoder for the deserialised VersionNumber is
looked up in the given list. The first match is used (using the semantics
of lookup). When no match is found, a decoder that fails with
UnknownVersion is returned.