packages feed

autodocodec 0.4.2.2 → 0.5.0.0

raw patch · 6 files changed

+58/−20 lines, 6 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Autodocodec.Aeson.Compat: keysSet :: KeyMap v -> Set Key
- Autodocodec: [ApCodec] :: ObjectCodec input (output -> newOutput) -> ObjectCodec input output -> ObjectCodec input newOutput
+ Autodocodec: [ApCodec] :: forall input output1 output. ObjectCodec input (output1 -> output) -> ObjectCodec input output1 -> Codec (KeyMap Value) input output
- Autodocodec: [ArrayOfCodec] :: (Coercible a (Vector input), Coercible b (Vector output)) => Maybe Text -> ValueCodec input output -> ValueCodec a b
+ Autodocodec: [ArrayOfCodec] :: forall input input1 output output1. (Coercible input (Vector input1), Coercible output (Vector output1)) => Maybe Text -> ValueCodec input1 output1 -> Codec Value input output
- Autodocodec: [BimapCodec] :: (oldOutput -> Either String newOutput) -> (newInput -> oldInput) -> Codec context oldInput oldOutput -> Codec context newInput newOutput
+ Autodocodec: [BimapCodec] :: forall oldOutput output input oldInput context. (oldOutput -> Either String output) -> (input -> oldInput) -> Codec context oldInput oldOutput -> Codec context input output
- Autodocodec: [BoolCodec] :: (Coercible a Bool, Coercible b Bool) => Maybe Text -> ValueCodec a b
+ Autodocodec: [BoolCodec] :: forall input output. (Coercible input Bool, Coercible output Bool) => Maybe Text -> Codec Value input output
- Autodocodec: [CommentCodec] :: Text -> ValueCodec input output -> ValueCodec input output
+ Autodocodec: [CommentCodec] :: forall input output. Text -> ValueCodec input output -> Codec Value input output
- Autodocodec: [DiscriminatedUnionCodec] :: Text -> (input -> (Discriminator, ObjectCodec input ())) -> HashMap Discriminator (Text, ObjectCodec Void output) -> ObjectCodec input output
+ Autodocodec: [DiscriminatedUnionCodec] :: forall input output. Text -> (input -> (Discriminator, ObjectCodec input ())) -> HashMap Discriminator (Text, ObjectCodec Void output) -> Codec (KeyMap Value) input output
- Autodocodec: [EitherCodec] :: (Coercible a (Either input1 input2), Coercible b (Either output1 output2)) => !Union -> Codec context input1 output1 -> Codec context input2 output2 -> Codec context a b
+ Autodocodec: [EitherCodec] :: forall input input1 input2 output output1 output2 context. (Coercible input (Either input1 input2), Coercible output (Either output1 output2)) => !Union -> Codec context input1 output1 -> Codec context input2 output2 -> Codec context input output
- Autodocodec: [EqCodec] :: (Show value, Eq value, Coercible a value, Coercible b value) => value -> JSONCodec value -> ValueCodec a b
+ Autodocodec: [EqCodec] :: forall value input output. (Show value, Eq value, Coercible input value, Coercible output value) => value -> JSONCodec value -> Codec Value input output
- Autodocodec: [HashMapCodec] :: (Eq k, Hashable k, FromJSONKey k, ToJSONKey k, Coercible a (HashMap k v), Coercible b (HashMap k v)) => JSONCodec v -> ValueCodec a b
+ Autodocodec: [HashMapCodec] :: forall k input v output. (Eq k, Hashable k, FromJSONKey k, ToJSONKey k, Coercible input (HashMap k v), Coercible output (HashMap k v)) => JSONCodec v -> Codec Value input output
- Autodocodec: [IntegerCodec] :: (Coercible a Integer, Coercible b Integer) => Maybe Text -> Bounds Integer -> ValueCodec a b
+ Autodocodec: [IntegerCodec] :: forall input output. (Coercible input Integer, Coercible output Integer) => Maybe Text -> Bounds Integer -> Codec Value input output
- Autodocodec: [MapCodec] :: (Ord k, FromJSONKey k, ToJSONKey k, Coercible a (Map k v), Coercible b (Map k v)) => JSONCodec v -> ValueCodec a b
+ Autodocodec: [MapCodec] :: forall k input v output. (Ord k, FromJSONKey k, ToJSONKey k, Coercible input (Map k v), Coercible output (Map k v)) => JSONCodec v -> Codec Value input output
- Autodocodec: [NullCodec] :: (Coercible a (), Coercible b ()) => ValueCodec a b
+ Autodocodec: [NullCodec] :: forall input output. (Coercible input (), Coercible output ()) => Codec Value input output
- Autodocodec: [NumberCodec] :: (Coercible a Scientific, Coercible b Scientific) => Maybe Text -> Bounds Scientific -> ValueCodec a b
+ Autodocodec: [NumberCodec] :: forall input output. (Coercible input Scientific, Coercible output Scientific) => Maybe Text -> Bounds Scientific -> Codec Value input output
- Autodocodec: [ObjectOfCodec] :: Maybe Text -> ObjectCodec input output -> ValueCodec input output
+ Autodocodec: [ObjectOfCodec] :: forall input output. Maybe Text -> ObjectCodec input output -> Codec Value input output
- Autodocodec: [OptionalKeyCodec] :: (Coercible a (Maybe input), Coercible b (Maybe output)) => Text -> ValueCodec input output -> Maybe Text -> ObjectCodec a b
+ Autodocodec: [OptionalKeyCodec] :: forall input input1 output output1. (Coercible input (Maybe input1), Coercible output (Maybe output1)) => Text -> ValueCodec input1 output1 -> Maybe Text -> Codec (KeyMap Value) input output
- Autodocodec: [OptionalKeyWithDefaultCodec] :: Coercible b value => Text -> ValueCodec value value -> value -> Maybe Text -> ObjectCodec value b
+ Autodocodec: [OptionalKeyWithDefaultCodec] :: forall output input. Coercible output input => Text -> ValueCodec input input -> input -> Maybe Text -> Codec (KeyMap Value) input output
- Autodocodec: [OptionalKeyWithOmittedDefaultCodec] :: (Eq value, Coercible a value, Coercible b value) => Text -> ValueCodec value value -> value -> Maybe Text -> ObjectCodec a b
+ Autodocodec: [OptionalKeyWithOmittedDefaultCodec] :: forall value input output. (Eq value, Coercible input value, Coercible output value) => Text -> ValueCodec value value -> value -> Maybe Text -> Codec (KeyMap Value) input output
- Autodocodec: [PureCodec] :: output -> ObjectCodec void output
+ Autodocodec: [PureCodec] :: forall output input. output -> Codec (KeyMap Value) input output
- Autodocodec: [ReferenceCodec] :: Text -> ~ValueCodec input output -> ValueCodec input output
+ Autodocodec: [ReferenceCodec] :: forall input output. Text -> ~ValueCodec input output -> Codec Value input output
- Autodocodec: [RequiredKeyCodec] :: Text -> ValueCodec input output -> Maybe Text -> ObjectCodec input output
+ Autodocodec: [RequiredKeyCodec] :: forall input input1 output output1. (Coercible input input1, Coercible output output1) => Text -> ValueCodec input1 output1 -> Maybe Text -> Codec (KeyMap Value) input output
- Autodocodec: [StringCodec] :: (Coercible a Text, Coercible b Text) => Maybe Text -> ValueCodec a b
+ Autodocodec: [StringCodec] :: forall input output. (Coercible input Text, Coercible output Text) => Maybe Text -> Codec Value input output
- Autodocodec: [ValueCodec] :: (Coercible Value a, Coercible Value b) => ValueCodec a b
+ Autodocodec: [ValueCodec] :: forall input output. (Coercible Value input, Coercible Value output) => Codec Value input output
- Autodocodec: boundedEnumCodec :: forall enum. (Eq enum, Enum enum, Bounded enum) => (enum -> Text) -> JSONCodec enum
+ Autodocodec: boundedEnumCodec :: (Eq enum, Enum enum, Bounded enum) => (enum -> Text) -> JSONCodec enum
- Autodocodec: boundedIntegralCodec :: forall i. (Integral i, Bounded i) => JSONCodec i
+ Autodocodec: boundedIntegralCodec :: (Integral i, Bounded i) => JSONCodec i
- Autodocodec: enumCodec :: forall enum context. Eq enum => NonEmpty (enum, Codec context enum enum) -> Codec context enum enum
+ Autodocodec: enumCodec :: Eq enum => NonEmpty (enum, Codec context enum enum) -> Codec context enum enum
- Autodocodec: optionalFieldOrNull :: forall output. HasCodec output => Text -> Text -> ObjectCodec (Maybe output) (Maybe output)
+ Autodocodec: optionalFieldOrNull :: HasCodec output => Text -> Text -> ObjectCodec (Maybe output) (Maybe output)
- Autodocodec: optionalFieldOrNull' :: forall output. HasCodec output => Text -> ObjectCodec (Maybe output) (Maybe output)
+ Autodocodec: optionalFieldOrNull' :: HasCodec output => Text -> ObjectCodec (Maybe output) (Maybe output)
- Autodocodec: shownBoundedEnumCodec :: forall enum. (Show enum, Eq enum, Enum enum, Bounded enum) => JSONCodec enum
+ Autodocodec: shownBoundedEnumCodec :: (Show enum, Eq enum, Enum enum, Bounded enum) => JSONCodec enum
- Autodocodec: stringConstCodec :: forall constant. Eq constant => NonEmpty (constant, Text) -> JSONCodec constant
+ Autodocodec: stringConstCodec :: Eq constant => NonEmpty (constant, Text) -> JSONCodec constant
- Autodocodec.Class: optionalFieldOrNull :: forall output. HasCodec output => Text -> Text -> ObjectCodec (Maybe output) (Maybe output)
+ Autodocodec.Class: optionalFieldOrNull :: HasCodec output => Text -> Text -> ObjectCodec (Maybe output) (Maybe output)
- Autodocodec.Class: optionalFieldOrNull' :: forall output. HasCodec output => Text -> ObjectCodec (Maybe output) (Maybe output)
+ Autodocodec.Class: optionalFieldOrNull' :: HasCodec output => Text -> ObjectCodec (Maybe output) (Maybe output)
- Autodocodec.Codec: [ApCodec] :: ObjectCodec input (output -> newOutput) -> ObjectCodec input output -> ObjectCodec input newOutput
+ Autodocodec.Codec: [ApCodec] :: forall input output1 output. ObjectCodec input (output1 -> output) -> ObjectCodec input output1 -> Codec (KeyMap Value) input output
- Autodocodec.Codec: [ArrayOfCodec] :: (Coercible a (Vector input), Coercible b (Vector output)) => Maybe Text -> ValueCodec input output -> ValueCodec a b
+ Autodocodec.Codec: [ArrayOfCodec] :: forall input input1 output output1. (Coercible input (Vector input1), Coercible output (Vector output1)) => Maybe Text -> ValueCodec input1 output1 -> Codec Value input output
- Autodocodec.Codec: [BimapCodec] :: (oldOutput -> Either String newOutput) -> (newInput -> oldInput) -> Codec context oldInput oldOutput -> Codec context newInput newOutput
+ Autodocodec.Codec: [BimapCodec] :: forall oldOutput output input oldInput context. (oldOutput -> Either String output) -> (input -> oldInput) -> Codec context oldInput oldOutput -> Codec context input output
- Autodocodec.Codec: [BoolCodec] :: (Coercible a Bool, Coercible b Bool) => Maybe Text -> ValueCodec a b
+ Autodocodec.Codec: [BoolCodec] :: forall input output. (Coercible input Bool, Coercible output Bool) => Maybe Text -> Codec Value input output
- Autodocodec.Codec: [CommentCodec] :: Text -> ValueCodec input output -> ValueCodec input output
+ Autodocodec.Codec: [CommentCodec] :: forall input output. Text -> ValueCodec input output -> Codec Value input output
- Autodocodec.Codec: [DiscriminatedUnionCodec] :: Text -> (input -> (Discriminator, ObjectCodec input ())) -> HashMap Discriminator (Text, ObjectCodec Void output) -> ObjectCodec input output
+ Autodocodec.Codec: [DiscriminatedUnionCodec] :: forall input output. Text -> (input -> (Discriminator, ObjectCodec input ())) -> HashMap Discriminator (Text, ObjectCodec Void output) -> Codec (KeyMap Value) input output
- Autodocodec.Codec: [EitherCodec] :: (Coercible a (Either input1 input2), Coercible b (Either output1 output2)) => !Union -> Codec context input1 output1 -> Codec context input2 output2 -> Codec context a b
+ Autodocodec.Codec: [EitherCodec] :: forall input input1 input2 output output1 output2 context. (Coercible input (Either input1 input2), Coercible output (Either output1 output2)) => !Union -> Codec context input1 output1 -> Codec context input2 output2 -> Codec context input output
- Autodocodec.Codec: [EqCodec] :: (Show value, Eq value, Coercible a value, Coercible b value) => value -> JSONCodec value -> ValueCodec a b
+ Autodocodec.Codec: [EqCodec] :: forall value input output. (Show value, Eq value, Coercible input value, Coercible output value) => value -> JSONCodec value -> Codec Value input output
- Autodocodec.Codec: [HashMapCodec] :: (Eq k, Hashable k, FromJSONKey k, ToJSONKey k, Coercible a (HashMap k v), Coercible b (HashMap k v)) => JSONCodec v -> ValueCodec a b
+ Autodocodec.Codec: [HashMapCodec] :: forall k input v output. (Eq k, Hashable k, FromJSONKey k, ToJSONKey k, Coercible input (HashMap k v), Coercible output (HashMap k v)) => JSONCodec v -> Codec Value input output
- Autodocodec.Codec: [IntegerCodec] :: (Coercible a Integer, Coercible b Integer) => Maybe Text -> Bounds Integer -> ValueCodec a b
+ Autodocodec.Codec: [IntegerCodec] :: forall input output. (Coercible input Integer, Coercible output Integer) => Maybe Text -> Bounds Integer -> Codec Value input output
- Autodocodec.Codec: [MapCodec] :: (Ord k, FromJSONKey k, ToJSONKey k, Coercible a (Map k v), Coercible b (Map k v)) => JSONCodec v -> ValueCodec a b
+ Autodocodec.Codec: [MapCodec] :: forall k input v output. (Ord k, FromJSONKey k, ToJSONKey k, Coercible input (Map k v), Coercible output (Map k v)) => JSONCodec v -> Codec Value input output
- Autodocodec.Codec: [NullCodec] :: (Coercible a (), Coercible b ()) => ValueCodec a b
+ Autodocodec.Codec: [NullCodec] :: forall input output. (Coercible input (), Coercible output ()) => Codec Value input output
- Autodocodec.Codec: [NumberCodec] :: (Coercible a Scientific, Coercible b Scientific) => Maybe Text -> Bounds Scientific -> ValueCodec a b
+ Autodocodec.Codec: [NumberCodec] :: forall input output. (Coercible input Scientific, Coercible output Scientific) => Maybe Text -> Bounds Scientific -> Codec Value input output
- Autodocodec.Codec: [ObjectOfCodec] :: Maybe Text -> ObjectCodec input output -> ValueCodec input output
+ Autodocodec.Codec: [ObjectOfCodec] :: forall input output. Maybe Text -> ObjectCodec input output -> Codec Value input output
- Autodocodec.Codec: [OptionalKeyCodec] :: (Coercible a (Maybe input), Coercible b (Maybe output)) => Text -> ValueCodec input output -> Maybe Text -> ObjectCodec a b
+ Autodocodec.Codec: [OptionalKeyCodec] :: forall input input1 output output1. (Coercible input (Maybe input1), Coercible output (Maybe output1)) => Text -> ValueCodec input1 output1 -> Maybe Text -> Codec (KeyMap Value) input output
- Autodocodec.Codec: [OptionalKeyWithDefaultCodec] :: Coercible b value => Text -> ValueCodec value value -> value -> Maybe Text -> ObjectCodec value b
+ Autodocodec.Codec: [OptionalKeyWithDefaultCodec] :: forall output input. Coercible output input => Text -> ValueCodec input input -> input -> Maybe Text -> Codec (KeyMap Value) input output
- Autodocodec.Codec: [OptionalKeyWithOmittedDefaultCodec] :: (Eq value, Coercible a value, Coercible b value) => Text -> ValueCodec value value -> value -> Maybe Text -> ObjectCodec a b
+ Autodocodec.Codec: [OptionalKeyWithOmittedDefaultCodec] :: forall value input output. (Eq value, Coercible input value, Coercible output value) => Text -> ValueCodec value value -> value -> Maybe Text -> Codec (KeyMap Value) input output
- Autodocodec.Codec: [PureCodec] :: output -> ObjectCodec void output
+ Autodocodec.Codec: [PureCodec] :: forall output input. output -> Codec (KeyMap Value) input output
- Autodocodec.Codec: [ReferenceCodec] :: Text -> ~ValueCodec input output -> ValueCodec input output
+ Autodocodec.Codec: [ReferenceCodec] :: forall input output. Text -> ~ValueCodec input output -> Codec Value input output
- Autodocodec.Codec: [RequiredKeyCodec] :: Text -> ValueCodec input output -> Maybe Text -> ObjectCodec input output
+ Autodocodec.Codec: [RequiredKeyCodec] :: forall input input1 output output1. (Coercible input input1, Coercible output output1) => Text -> ValueCodec input1 output1 -> Maybe Text -> Codec (KeyMap Value) input output
- Autodocodec.Codec: [StringCodec] :: (Coercible a Text, Coercible b Text) => Maybe Text -> ValueCodec a b
+ Autodocodec.Codec: [StringCodec] :: forall input output. (Coercible input Text, Coercible output Text) => Maybe Text -> Codec Value input output
- Autodocodec.Codec: [ValueCodec] :: (Coercible Value a, Coercible Value b) => ValueCodec a b
+ Autodocodec.Codec: [ValueCodec] :: forall input output. (Coercible Value input, Coercible Value output) => Codec Value input output
- Autodocodec.Codec: boundedEnumCodec :: forall enum. (Eq enum, Enum enum, Bounded enum) => (enum -> Text) -> JSONCodec enum
+ Autodocodec.Codec: boundedEnumCodec :: (Eq enum, Enum enum, Bounded enum) => (enum -> Text) -> JSONCodec enum
- Autodocodec.Codec: boundedIntegralBounds :: forall i. (Integral i, Bounded i) => Bounds Integer
+ Autodocodec.Codec: boundedIntegralBounds :: (Integral i, Bounded i) => Bounds Integer
- Autodocodec.Codec: boundedIntegralCodec :: forall i. (Integral i, Bounded i) => JSONCodec i
+ Autodocodec.Codec: boundedIntegralCodec :: (Integral i, Bounded i) => JSONCodec i
- Autodocodec.Codec: enumCodec :: forall enum context. Eq enum => NonEmpty (enum, Codec context enum enum) -> Codec context enum enum
+ Autodocodec.Codec: enumCodec :: Eq enum => NonEmpty (enum, Codec context enum enum) -> Codec context enum enum
- Autodocodec.Codec: shownBoundedEnumCodec :: forall enum. (Show enum, Eq enum, Enum enum, Bounded enum) => JSONCodec enum
+ Autodocodec.Codec: shownBoundedEnumCodec :: (Show enum, Eq enum, Enum enum, Bounded enum) => JSONCodec enum
- Autodocodec.Codec: stringConstCodec :: forall constant. Eq constant => NonEmpty (constant, Text) -> JSONCodec constant
+ Autodocodec.Codec: stringConstCodec :: Eq constant => NonEmpty (constant, Text) -> JSONCodec constant

Files

CHANGELOG.md view
@@ -1,5 +1,14 @@ # Changelog +## [0.5.0.0] - 2025-06-20++This is technically a breaking change but it's unlikely that you'll need to+change any of your codecs.++### Changed++* Added the same `Coercible` trick to the `RequiredKeyCodec` constructor of a codec.+ ## [0.4.2.2] - 2024-09-01  ### Added
autodocodec.cabal view
@@ -1,11 +1,11 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.36.0.+-- This file has been generated from package.yaml by hpack version 0.36.1. -- -- see: https://github.com/sol/hpack  name:           autodocodec-version:        0.4.2.2+version:        0.5.0.0 synopsis:       Self-documenting encoder and decoder homepage:       https://github.com/NorfairKing/autodocodec#readme bug-reports:    https://github.com/NorfairKing/autodocodec/issues
src/Autodocodec/Aeson/Compat.hs view
@@ -5,12 +5,17 @@ #if MIN_VERSION_aeson(2,0,0) import Data.Aeson.Key (Key) import qualified Data.Aeson.Key as K+import Data.Aeson.KeyMap (KeyMap) import qualified Data.Aeson.KeyMap as KM #else import qualified Data.HashMap.Strict as HM+import qualified Data.HashSet as HS+import qualified Data.Map as M #endif import qualified Data.Aeson as JSON import qualified Data.Aeson.Types as JSON+import Data.Set (Set)+import qualified Data.Set as S import Data.Text (Text)  #if MIN_VERSION_aeson(2,0,0)@@ -30,60 +35,83 @@ #endif  #if MIN_VERSION_aeson(2,0,0)-lookupKey :: Key -> KM.KeyMap v -> Maybe v+lookupKey :: Key -> KeyMap v -> Maybe v lookupKey = KM.lookup #else-lookupKey :: Text -> HM.HashMap Text v -> Maybe v+lookupKey :: Text -> HashMap Text v -> Maybe v lookupKey = HM.lookup #endif  #if MIN_VERSION_aeson(2,0,0)-insert :: Key -> v -> KM.KeyMap v -> KM.KeyMap v+insert :: Key -> v -> KeyMap v -> KeyMap v insert = KM.insert #else-insert :: Text -> v -> HM.HashMap Text v -> HM.HashMap Text v+insert :: Text -> v -> HashMap Text v -> HashMap Text v insert = HM.insert #endif  #if MIN_VERSION_aeson(2,0,0)-fromList :: [(Key, v)] -> KM.KeyMap v+fromList :: [(Key, v)] -> KeyMap v fromList = KM.fromList #else-fromList :: [(Text, v)] -> HM.HashMap Text v+fromList :: [(Text, v)] -> HashMap Text v fromList = HM.fromList #endif  #if MIN_VERSION_aeson(2,0,0)-toList ::  KM.KeyMap v -> [(Key, v)]+toList :: KeyMap v -> [(Key, v)] toList = KM.toList #else-toList ::HM.HashMap Text v -> [(Text, v)]+toList :: HashMap Text v -> [(Text, v)] toList = HM.toList #endif  #if MIN_VERSION_aeson(2,0,0)-map ::  (v1 -> v2) -> KM.KeyMap v1 -> KM.KeyMap v2+keysSet :: KeyMap v -> Set Key+keysSet = S.fromList .  KM.keys+#else+keysSet :: HashHashMap Text v -> Set Key+keysSet = S.fromList . HS.toList . HM.keysSet+#endif++#if MIN_VERSION_aeson(2,0,0)+map :: (v1 -> v2) -> KeyMap v1 -> KeyMap v2 map = KM.map #else-map ::  (v1 -> v2) -> HM.HashMap Text v1 -> HM.HashMap Text v2+map :: (v1 -> v2) -> HashMap Text v1 -> HashMap Text v2 map = HM.map #endif -liftToJSON :: (JSON.ToJSON1 f) => (a -> JSON.Value) -> ([a] -> JSON.Value) -> f a -> JSON.Value+liftToJSON ::+  (JSON.ToJSON1 f) =>+  (a -> JSON.Value) ->+  ([a] -> JSON.Value) ->+  f a ->+  JSON.Value #if MIN_VERSION_aeson(2,2,0) liftToJSON = JSON.liftToJSON (const False) #else liftToJSON = JSON.liftToJSON #endif -liftToEncoding :: (JSON.ToJSON1 f) => (a -> JSON.Encoding) -> ([a] -> JSON.Encoding) -> f a -> JSON.Encoding+liftToEncoding ::+  (JSON.ToJSON1 f) =>+  (a -> JSON.Encoding) ->+  ([a] -> JSON.Encoding) ->+  f a ->+  JSON.Encoding #if MIN_VERSION_aeson(2,2,0) liftToEncoding = JSON.liftToEncoding (const False) #else liftToEncoding = JSON.liftToEncoding #endif -liftParseJSON :: (JSON.FromJSON1 f) => (JSON.Value -> JSON.Parser a) -> (JSON.Value -> JSON.Parser [a]) -> JSON.Value -> JSON.Parser (f a)+liftParseJSON ::+  (JSON.FromJSON1 f) =>+  (JSON.Value -> JSON.Parser a) ->+  (JSON.Value -> JSON.Parser [a]) ->+  JSON.Value ->+  JSON.Parser (f a) #if MIN_VERSION_aeson(2,2,0) liftParseJSON = JSON.liftParseJSON Nothing #else
src/Autodocodec/Aeson/Decode.hs view
@@ -144,8 +144,8 @@                   Left err -> prependFailure ("  Previous branch failure: " <> err <> "\n") (rightParser value)               DisjointUnion ->                 case (parseEither leftParser value, parseEither rightParser value) of-                  (Left _, Right r) -> pure r                   (Right l, Left _) -> pure l+                  (Left _, Right r) -> pure r                   (Right _, Right _) -> fail "Both branches of a disjoint union succeeded."                   (Left lErr, Left rErr) ->                     fail $@@ -164,7 +164,7 @@       ReferenceCodec _ c -> go value c       RequiredKeyCodec k c _ -> do         valueAtKey <- (value :: JSON.Object) JSON..: Compat.toKey k-        go valueAtKey c JSON.<?> Key (Compat.toKey k)+        coerce $ go valueAtKey c JSON.<?> Key (Compat.toKey k)       OptionalKeyCodec k c _ -> do         let key = Compat.toKey k             mValueAtKey = Compat.lookupKey key (value :: JSON.Object)
src/Autodocodec/Aeson/Encode.hs view
@@ -44,7 +44,7 @@   where     go :: a -> ObjectCodec a void -> JSON.Object     go a = \case-      RequiredKeyCodec k c _ -> Compat.toKey k JSON..= toJSONVia c a+      RequiredKeyCodec k c _ -> Compat.toKey k JSON..= toJSONVia c (coerce a)       OptionalKeyCodec k c _ -> case (coerce a :: Maybe _) of         Nothing -> mempty         Just b -> Compat.toKey k JSON..= toJSONVia c b@@ -102,7 +102,7 @@   where     goObject :: a -> ObjectCodec a void -> JSON.Series     goObject a = \case-      RequiredKeyCodec k c _ -> JSON.pair (Compat.toKey k) (toEncodingVia c a)+      RequiredKeyCodec k c _ -> JSON.pair (Compat.toKey k) (toEncodingVia c (coerce a))       OptionalKeyCodec k c _ -> case (coerce a :: Maybe _) of         Nothing -> mempty :: JSON.Series         Just b -> JSON.pair (Compat.toKey k) (toEncodingVia c b)
src/Autodocodec/Codec.hs view
@@ -240,13 +240,14 @@     ~(ValueCodec input output) ->     ValueCodec input output   RequiredKeyCodec ::+    (Coercible a input, Coercible b output) =>     -- | Key     Text ->     -- | Codec for the value     ValueCodec input output ->     -- | Documentation     Maybe Text ->-    ObjectCodec input output+    ObjectCodec a b   OptionalKeyCodec ::     (Coercible a (Maybe input), Coercible b (Maybe output)) =>     -- | Key