versioning-0.2.0.0: Type-safe data versioning.

Safe HaskellNone
LanguageHaskell2010

Versioning.JSON

Description

JSON-specific 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 JsonDecodableTo v a = DecodableTo FromJSON v a Source #

Handy constraint synonym to be used with fromJsonAnyVersion

fromJsonAnyVersion :: forall v a. JsonDecodableTo v a => ByteString -> Maybe (a v) Source #

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

fromJsonAnyVersionStrict :: forall v a. JsonDecodableTo v a => ByteString -> Maybe (a v) Source #

Like fromJsonAnyVersion but it reads from a strict ByteString

fromJsonAnyVersionEither :: forall v a. JsonDecodableTo v a => ByteString -> Either String (a v) Source #

Like fromJsonAnyVersion but returns a message when decoding fails

fromJsonAnyVersionEitherStrict :: forall v a. JsonDecodableTo v a => ByteString -> Either String (a v) Source #

Like fromJsonAnyVersionStrict but returns a message when decoding fails

withJsonAnyVersion :: forall c a v. (WithAnyVersion v a c FromJSON, c (a v)) => Apply a c -> ByteString -> Maybe (Applied c a) Source #

Decode a JSON string by trying all the versions decrementally and apply a pure function to the decoded object at its original version.

withJsonAnyVersionStrict :: forall c a v. (WithAnyVersion v a c FromJSON, c (a v)) => Apply a c -> ByteString -> Maybe (Applied c a) Source #

Like withJsonAnyVersion but it reads from a strict ByteString

withJsonAnyVersionEither :: forall c a v. (WithAnyVersion v a c FromJSON, c (a v)) => Apply a c -> ByteString -> Either String (Applied c a) Source #

Like withJsonAnyVersion but returns a message when decoding fails

withJsonAnyVersionEitherStrict :: forall c a v. (WithAnyVersion v a c FromJSON, c (a v)) => Apply a c -> ByteString -> Either String (Applied c a) Source #

Like withJsonAnyVersionStrict but returns a message when decoding fails

withJsonAnyVersionM :: forall c a v m. (WithAnyVersion v a c FromJSON, Applicative m, c (a v)) => ApplyM m a c -> ByteString -> m (Maybe (Applied c a)) Source #

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

withJsonAnyVersionStrictM :: forall c a v m. (WithAnyVersion v a c FromJSON, Applicative m, c (a v)) => ApplyM m a c -> ByteString -> m (Maybe (Applied c a)) Source #

Like withJsonAnyVersionM but it reads from a strict ByteString

withJsonAnyVersionEitherM :: forall c a v m. (WithAnyVersion v a c FromJSON, Applicative m, c (a v)) => ApplyM m a c -> ByteString -> m (Either String (Applied c a)) Source #

Like withJsonAnyVersionM but returns a message when decoding fails

withJsonAnyVersionEitherStrictM :: forall c a v m. (WithAnyVersion v a c FromJSON, Applicative m, c (a v)) => ApplyM m a c -> ByteString -> m (Either String (Applied c a)) Source #

Like withJsonAnyVersionStrictM but returns a message when decoding fails