{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeInType #-}
{-# LANGUAGE UndecidableInstances #-}
module Versioning.JSON
(
Applied
, JsonDecodableTo
, JsonDecodableToFrom
, fromJsonAnyVersion
, fromJsonAnyVersionStrict
, fromJsonAnyVersionEither
, fromJsonAnyVersionEitherStrict
, fromJsonAnyVersionFrom
, withJsonAnyVersion
, withJsonAnyVersionStrict
, withJsonAnyVersionEither
, withJsonAnyVersionEitherStrict
, withJsonAnyVersionFrom
, withJsonAnyVersionM
, withJsonAnyVersionStrictM
, withJsonAnyVersionEitherM
, withJsonAnyVersionEitherStrictM
, withJsonAnyVersionFromM
)
where
import Data.Aeson (FromJSON, decode, decodeStrict,
eitherDecode, eitherDecodeStrict)
import qualified Data.ByteString as StrictBS
import qualified Data.ByteString.Lazy as LazyBS
import Versioning.Base
import Versioning.Internal.Decoding
fromJsonAnyVersion
:: forall v a . JsonDecodableTo v a => LazyBS.ByteString -> Maybe (a v)
fromJsonAnyVersion :: ByteString -> Maybe (a v)
fromJsonAnyVersion = Decoder FromJSON ByteString Maybe a -> ByteString -> Maybe (a v)
forall (v :: V) (a :: V -> *) (dec :: * -> Constraint) enc
(t :: * -> *).
(Alt t, Applicative t, DecodableTo dec v a) =>
Decoder dec enc t a -> enc -> t (a v)
decodeAnyVersion Decoder FromJSON ByteString Maybe a
forall k (a :: k -> *). Decoder FromJSON ByteString Maybe a
jsonDecode
fromJsonAnyVersionStrict
:: forall v a . JsonDecodableTo v a => StrictBS.ByteString -> Maybe (a v)
fromJsonAnyVersionStrict :: ByteString -> Maybe (a v)
fromJsonAnyVersionStrict = Decoder FromJSON ByteString Maybe a -> ByteString -> Maybe (a v)
forall (v :: V) (a :: V -> *) (dec :: * -> Constraint) enc
(t :: * -> *).
(Alt t, Applicative t, DecodableTo dec v a) =>
Decoder dec enc t a -> enc -> t (a v)
decodeAnyVersion Decoder FromJSON ByteString Maybe a
forall k (a :: k -> *). Decoder FromJSON ByteString Maybe a
jsonDecodeStrict
fromJsonAnyVersionEither
:: forall v a
. JsonDecodableTo v a
=> LazyBS.ByteString
-> Either String (a v)
fromJsonAnyVersionEither :: ByteString -> Either String (a v)
fromJsonAnyVersionEither = Decoder FromJSON ByteString (Either String) a
-> ByteString -> Either String (a v)
forall (v :: V) (a :: V -> *) (dec :: * -> Constraint) enc
(t :: * -> *).
(Alt t, Applicative t, DecodableTo dec v a) =>
Decoder dec enc t a -> enc -> t (a v)
decodeAnyVersion Decoder FromJSON ByteString (Either String) a
forall k (a :: k -> *).
Decoder FromJSON ByteString (Either String) a
jsonEitherDecode
fromJsonAnyVersionEitherStrict
:: forall v a
. JsonDecodableTo v a
=> StrictBS.ByteString
-> Either String (a v)
fromJsonAnyVersionEitherStrict :: ByteString -> Either String (a v)
fromJsonAnyVersionEitherStrict = Decoder FromJSON ByteString (Either String) a
-> ByteString -> Either String (a v)
forall (v :: V) (a :: V -> *) (dec :: * -> Constraint) enc
(t :: * -> *).
(Alt t, Applicative t, DecodableTo dec v a) =>
Decoder dec enc t a -> enc -> t (a v)
decodeAnyVersion Decoder FromJSON ByteString (Either String) a
forall k (a :: k -> *).
Decoder FromJSON ByteString (Either String) a
jsonEitherDecodeStrict
fromJsonAnyVersionFrom
:: forall from v a
. JsonDecodableToFrom from v a
=> LazyBS.ByteString
-> Maybe (a v)
fromJsonAnyVersionFrom :: ByteString -> Maybe (a v)
fromJsonAnyVersionFrom = Decoder FromJSON ByteString Maybe a -> ByteString -> Maybe (a v)
forall (from :: V) (v :: V) (a :: V -> *) (dec :: * -> Constraint)
enc (t :: * -> *).
(Alt t, Applicative t, DecodableToFrom from dec v a) =>
Decoder dec enc t a -> enc -> t (a v)
decodeAnyVersionFrom @from Decoder FromJSON ByteString Maybe a
forall k (a :: k -> *). Decoder FromJSON ByteString Maybe a
jsonDecode
withJsonAnyVersionM
:: forall c a v m
. (WithAnyVersion v a c FromJSON, Applicative m, c (a v))
=> ApplyM m a c
-> LazyBS.ByteString
-> m (Maybe (Applied c a))
withJsonAnyVersionM :: ApplyM m a c -> ByteString -> m (Maybe (Applied c a))
withJsonAnyVersionM = Decoder FromJSON ByteString Maybe a
-> ApplyM m a c -> ByteString -> m (Maybe (Applied c a))
forall (v :: V) (c :: * -> Constraint) (a :: V -> *)
(dec :: * -> Constraint) 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))
withAnyVersionM @v @c @a Decoder FromJSON ByteString Maybe a
forall k (a :: k -> *). Decoder FromJSON ByteString Maybe a
jsonDecode
withJsonAnyVersionStrictM
:: forall c a v m
. (WithAnyVersion v a c FromJSON, Applicative m, c (a v))
=> ApplyM m a c
-> StrictBS.ByteString
-> m (Maybe (Applied c a))
withJsonAnyVersionStrictM :: ApplyM m a c -> ByteString -> m (Maybe (Applied c a))
withJsonAnyVersionStrictM = Decoder FromJSON ByteString Maybe a
-> ApplyM m a c -> ByteString -> m (Maybe (Applied c a))
forall (v :: V) (c :: * -> Constraint) (a :: V -> *)
(dec :: * -> Constraint) 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))
withAnyVersionM @v @c @a Decoder FromJSON ByteString Maybe a
forall k (a :: k -> *). Decoder FromJSON ByteString Maybe a
jsonDecodeStrict
withJsonAnyVersionEitherM
:: forall c a v m
. (WithAnyVersion v a c FromJSON, Applicative m, c (a v))
=> ApplyM m a c
-> LazyBS.ByteString
-> m (Either String (Applied c a))
withJsonAnyVersionEitherM :: ApplyM m a c -> ByteString -> m (Either String (Applied c a))
withJsonAnyVersionEitherM = Decoder FromJSON ByteString (Either String) a
-> ApplyM m a c -> ByteString -> m (Either String (Applied c a))
forall (v :: V) (c :: * -> Constraint) (a :: V -> *)
(dec :: * -> Constraint) 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))
withAnyVersionM @v @c @a Decoder FromJSON ByteString (Either String) a
forall k (a :: k -> *).
Decoder FromJSON ByteString (Either String) a
jsonEitherDecode
withJsonAnyVersionEitherStrictM
:: forall c a v m
. (WithAnyVersion v a c FromJSON, Applicative m, c (a v))
=> ApplyM m a c
-> StrictBS.ByteString
-> m (Either String (Applied c a))
withJsonAnyVersionEitherStrictM :: ApplyM m a c -> ByteString -> m (Either String (Applied c a))
withJsonAnyVersionEitherStrictM =
Decoder FromJSON ByteString (Either String) a
-> ApplyM m a c -> ByteString -> m (Either String (Applied c a))
forall (v :: V) (c :: * -> Constraint) (a :: V -> *)
(dec :: * -> Constraint) 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))
withAnyVersionM @v @c @a Decoder FromJSON ByteString (Either String) a
forall k (a :: k -> *).
Decoder FromJSON ByteString (Either String) a
jsonEitherDecodeStrict
withJsonAnyVersionFromM
:: forall from c a v m
. (WithAnyVersionFrom from v a c FromJSON, Applicative m, c (a v))
=> ApplyM m a c
-> LazyBS.ByteString
-> m (Maybe (Applied c a))
withJsonAnyVersionFromM :: ApplyM m a c -> ByteString -> m (Maybe (Applied c a))
withJsonAnyVersionFromM = Decoder FromJSON ByteString Maybe a
-> ApplyM m a c -> ByteString -> m (Maybe (Applied c a))
forall (from :: V) (v :: V) (c :: * -> Constraint) (a :: V -> *)
(dec :: * -> Constraint) enc (m :: * -> *) (t :: * -> *).
(WithAnyVersionFrom from 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))
withAnyVersionFromM @from @v @c @a Decoder FromJSON ByteString Maybe a
forall k (a :: k -> *). Decoder FromJSON ByteString Maybe a
jsonDecode
withJsonAnyVersion
:: forall c a v
. (WithAnyVersion v a c FromJSON, c (a v))
=> Apply a c
-> LazyBS.ByteString
-> Maybe (Applied c a)
withJsonAnyVersion :: Apply a c -> ByteString -> Maybe (Applied c a)
withJsonAnyVersion = Decoder FromJSON ByteString Maybe a
-> Apply a c -> ByteString -> Maybe (Applied c a)
forall (v :: V) (c :: * -> Constraint) (a :: V -> *)
(dec :: * -> Constraint) 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)
withAnyVersion @v @c @a Decoder FromJSON ByteString Maybe a
forall k (a :: k -> *). Decoder FromJSON ByteString Maybe a
jsonDecode
withJsonAnyVersionStrict
:: forall c a v
. (WithAnyVersion v a c FromJSON, c (a v))
=> Apply a c
-> StrictBS.ByteString
-> Maybe (Applied c a)
withJsonAnyVersionStrict :: Apply a c -> ByteString -> Maybe (Applied c a)
withJsonAnyVersionStrict = Decoder FromJSON ByteString Maybe a
-> Apply a c -> ByteString -> Maybe (Applied c a)
forall (v :: V) (c :: * -> Constraint) (a :: V -> *)
(dec :: * -> Constraint) 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)
withAnyVersion @v @c @a Decoder FromJSON ByteString Maybe a
forall k (a :: k -> *). Decoder FromJSON ByteString Maybe a
jsonDecodeStrict
withJsonAnyVersionEither
:: forall c a v
. (WithAnyVersion v a c FromJSON, c (a v))
=> Apply a c
-> LazyBS.ByteString
-> Either String (Applied c a)
withJsonAnyVersionEither :: Apply a c -> ByteString -> Either String (Applied c a)
withJsonAnyVersionEither = Decoder FromJSON ByteString (Either String) a
-> Apply a c -> ByteString -> Either String (Applied c a)
forall (v :: V) (c :: * -> Constraint) (a :: V -> *)
(dec :: * -> Constraint) 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)
withAnyVersion @v @c @a Decoder FromJSON ByteString (Either String) a
forall k (a :: k -> *).
Decoder FromJSON ByteString (Either String) a
jsonEitherDecode
withJsonAnyVersionEitherStrict
:: forall c a v
. (WithAnyVersion v a c FromJSON, c (a v))
=> Apply a c
-> StrictBS.ByteString
-> Either String (Applied c a)
withJsonAnyVersionEitherStrict :: Apply a c -> ByteString -> Either String (Applied c a)
withJsonAnyVersionEitherStrict = Decoder FromJSON ByteString (Either String) a
-> Apply a c -> ByteString -> Either String (Applied c a)
forall (v :: V) (c :: * -> Constraint) (a :: V -> *)
(dec :: * -> Constraint) 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)
withAnyVersion @v @c @a Decoder FromJSON ByteString (Either String) a
forall k (a :: k -> *).
Decoder FromJSON ByteString (Either String) a
jsonEitherDecodeStrict
withJsonAnyVersionFrom
:: forall from c a v
. (WithAnyVersionFrom from v a c FromJSON, c (a v))
=> Apply a c
-> LazyBS.ByteString
-> Maybe (Applied c a)
withJsonAnyVersionFrom :: Apply a c -> ByteString -> Maybe (Applied c a)
withJsonAnyVersionFrom = Decoder FromJSON ByteString Maybe a
-> Apply a c -> ByteString -> Maybe (Applied c a)
forall (from :: V) (v :: V) (c :: * -> Constraint) (a :: V -> *)
(dec :: * -> Constraint) enc (t :: * -> *).
(WithAnyVersionFrom from 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)
withAnyVersionFrom @from @v @c @a Decoder FromJSON ByteString Maybe a
forall k (a :: k -> *). Decoder FromJSON ByteString Maybe a
jsonDecode
jsonDecode :: Decoder FromJSON LazyBS.ByteString Maybe a
jsonDecode :: Decoder FromJSON ByteString Maybe a
jsonDecode = (forall (v :: k). FromJSON (a v) => ByteString -> Maybe (a v))
-> Decoder FromJSON ByteString Maybe a
forall k k (dec :: k -> Constraint) enc (t :: k -> *)
(a :: k -> k).
(forall (v :: k). dec (a v) => enc -> t (a v))
-> Decoder dec enc t a
Decoder forall (v :: k). FromJSON (a v) => ByteString -> Maybe (a v)
forall a. FromJSON a => ByteString -> Maybe a
decode
jsonDecodeStrict :: Decoder FromJSON StrictBS.ByteString Maybe a
jsonDecodeStrict :: Decoder FromJSON ByteString Maybe a
jsonDecodeStrict = (forall (v :: k). FromJSON (a v) => ByteString -> Maybe (a v))
-> Decoder FromJSON ByteString Maybe a
forall k k (dec :: k -> Constraint) enc (t :: k -> *)
(a :: k -> k).
(forall (v :: k). dec (a v) => enc -> t (a v))
-> Decoder dec enc t a
Decoder forall (v :: k). FromJSON (a v) => ByteString -> Maybe (a v)
forall a. FromJSON a => ByteString -> Maybe a
decodeStrict
jsonEitherDecode :: Decoder FromJSON LazyBS.ByteString (Either String) a
jsonEitherDecode :: Decoder FromJSON ByteString (Either String) a
jsonEitherDecode = (forall (v :: k).
FromJSON (a v) =>
ByteString -> Either String (a v))
-> Decoder FromJSON ByteString (Either String) a
forall k k (dec :: k -> Constraint) enc (t :: k -> *)
(a :: k -> k).
(forall (v :: k). dec (a v) => enc -> t (a v))
-> Decoder dec enc t a
Decoder forall (v :: k).
FromJSON (a v) =>
ByteString -> Either String (a v)
forall a. FromJSON a => ByteString -> Either String a
eitherDecode
jsonEitherDecodeStrict :: Decoder FromJSON StrictBS.ByteString (Either String) a
jsonEitherDecodeStrict :: Decoder FromJSON ByteString (Either String) a
jsonEitherDecodeStrict = (forall (v :: k).
FromJSON (a v) =>
ByteString -> Either String (a v))
-> Decoder FromJSON ByteString (Either String) a
forall k k (dec :: k -> Constraint) enc (t :: k -> *)
(a :: k -> k).
(forall (v :: k). dec (a v) => enc -> t (a v))
-> Decoder dec enc t a
Decoder forall (v :: k).
FromJSON (a v) =>
ByteString -> Either String (a v)
forall a. FromJSON a => ByteString -> Either String a
eitherDecodeStrict
type JsonDecodableTo v a = JsonDecodableToFrom V0 v a
type JsonDecodableToFrom from v a = DecodableToFrom from FromJSON v a