versioning-0.2.0.0: Type-safe data versioning.

Safe HaskellNone
LanguageHaskell2010

Versioning.Internal.Decoding

Description

Encoding-agnosting deserialization utilities.

Synopsis

Documentation

type family Applied (c :: Type -> Constraint) (a :: V -> Type) :: Type Source #

The result type of the action that has been applied to the decoded object with withAnyVersion or withAnyVersionM.

type Apply a c = forall v. c (a v) => a v -> Applied c a Source #

The pure function to apply to the decoded object with withAnyVersion

type ApplyM m a c = forall v. c (a v) => a v -> m (Applied c a) Source #

The action to apply to the decoded object with withAnyVersionM

type DecodableTo dec v a = DecodeAnyVersion v v a dec Source #

Handy constraint synonym to be used with decodeAnyVersion

class DecodeAnyVersion (v :: V) (w :: V) (a :: V -> Type) dec Source #

Minimal complete definition

decodeAnyVersion'

Instances

(DecodeAnyVersion (Decr v V1) w a dec, dec (a v), dec (a (Decr v V1)), Upgrade v w a) => DecodeAnyVersion v w a dec Source # 

Methods

decodeAnyVersion' :: (Alt t, Applicative t) => Decoder V * dec enc t a -> enc -> t (a w)

(dec (a V1), Upgrade V1 w a) => DecodeAnyVersion V1 w a dec Source # 

Methods

decodeAnyVersion' :: (Alt t, Applicative t) => Decoder V * dec enc t a -> enc -> t (a w)

newtype Decoder dec enc t a Source #

The function that will perform the actual decoding

Constructors

Decoder (forall v. dec (a v) => enc -> t (a v)) 

class WithAnyVersion (v :: V) (a :: V -> Type) c dec Source #

Minimal complete definition

withAnyVersion'

Instances

(WithAnyVersion (Decr v V1) a c dec, dec (a v), dec (a (Decr v V1)), c (a v), c (a (Decr v V1))) => WithAnyVersion v a c dec Source # 

Methods

withAnyVersion' :: (Applicative m, Alt t, Applicative t, Traversable t, c (a v)) => Decoder V * dec enc t a -> ApplyM m a c -> enc -> m (t (Applied c a))

(dec (a V1), c (a V1)) => WithAnyVersion V1 a c dec Source # 

Methods

withAnyVersion' :: (Applicative m, Alt t, Applicative t, Traversable t, c (a V1)) => Decoder V * dec enc t a -> ApplyM m a c -> enc -> m (t (Applied c a))

decodeAnyVersion :: forall v a dec enc t. (Alt t, Applicative t, DecodableTo dec v a) => Decoder dec enc t a -> enc -> t (a v) Source #

Decode by trying all the versions decrementally and upgrade the decoded object to the newest version.

withAnyVersion :: forall v c a dec enc t. (WithAnyVersion v a c dec, c (a v), Alt t, Applicative t, Traversable t) => Decoder dec enc t a -> Apply a c -> enc -> t (Applied c a) Source #

Pure version of withAnyVersionM.

withAnyVersionM :: forall v c a dec enc m t. (WithAnyVersion v a c dec, Alt t, Applicative t, Traversable t, Applicative m, c (a v)) => Decoder dec enc t a -> ApplyM m a c -> enc -> m (t (Applied c a)) Source #

Decode by trying all the versions decrementally and apply an action to the decoded object at its original version.