packages feed

autodocodec 0.2.0.5 → 0.2.0.6

raw patch · 5 files changed

+36/−11 lines, 5 filesPVP: minor bump suggested

API additions: PVP suggests at least a minor version bump

API changes (from Hackage documentation)

+ Autodocodec.Aeson.Compat: liftParseJSON :: FromJSON1 f => (Value -> Parser a) -> (Value -> Parser [a]) -> Value -> Parser (f a)
+ Autodocodec.Aeson.Compat: liftToEncoding :: ToJSON1 f => (a -> Encoding) -> ([a] -> Encoding) -> f a -> Encoding
+ Autodocodec.Aeson.Compat: liftToJSON :: ToJSON1 f => (a -> Value) -> ([a] -> Value) -> f a -> Value

Files

CHANGELOG.md view
@@ -1,5 +1,11 @@ # Changelog +## [0.2.0.6] - 2023-10-05++### Added++* Forward-compatibility with `aeson >= 2.2`.+ ## [0.2.0.5] - 2023-08-27  ### Added
autodocodec.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack  name:           autodocodec-version:        0.2.0.5+version:        0.2.0.6 synopsis:       Self-documenting encoder and decoder homepage:       https://github.com/NorfairKing/autodocodec#readme bug-reports:    https://github.com/NorfairKing/autodocodec/issues@@ -65,7 +65,3 @@       base >=4.7 && <5     , doctest   default-language: Haskell2010-  if impl(GHC > 9.2)-    buildable: True-  else-    buildable: False
src/Autodocodec/Aeson/Compat.hs view
@@ -9,6 +9,8 @@ #else import qualified Data.HashMap.Strict as HM #endif+import qualified Data.Aeson as JSON+import qualified Data.Aeson.Types as JSON import Data.Text (Text)  #if MIN_VERSION_aeson(2,0,0)@@ -65,4 +67,25 @@ #else map ::  (v1 -> v2) -> HM.HashMap Text v1 -> HM.HashMap Text v2 map = HM.map+#endif++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+#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)+#if MIN_VERSION_aeson(2,2,0)+liftParseJSON = JSON.liftParseJSON Nothing+#else+liftParseJSON = JSON.liftParseJSON #endif
src/Autodocodec/Aeson/Decode.hs view
@@ -94,8 +94,8 @@             Just name -> withObject (T.unpack name) f value         )           (\object_ -> (`go` c) (object_ :: JSON.Object))-      HashMapCodec c -> liftParseJSON (`go` c) (`go` listCodec c) value :: JSON.Parser (HashMap _ _)-      MapCodec c -> liftParseJSON (`go` c) (`go` listCodec c) value :: JSON.Parser (Map _ _)+      HashMapCodec c -> Compat.liftParseJSON (`go` c) (`go` listCodec c) value :: JSON.Parser (HashMap _ _)+      MapCodec c -> Compat.liftParseJSON (`go` c) (`go` listCodec c) value :: JSON.Parser (Map _ _)       ValueCodec -> pure (value :: JSON.Value)       EqCodec expected c -> do         actual <- go value c
src/Autodocodec/Aeson/Encode.hs view
@@ -78,8 +78,8 @@       NumberCodec _ _ -> toJSON (a :: Scientific)       ArrayOfCodec _ c -> toJSON (fmap (`go` c) (a :: Vector _))       ObjectOfCodec _ oc -> JSON.Object (toJSONObjectVia oc a)-      HashMapCodec c -> JSON.liftToJSON (`go` c) (`go` listCodec c) (a :: HashMap _ _)-      MapCodec c -> JSON.liftToJSON (`go` c) (`go` listCodec c) (a :: Map _ _)+      HashMapCodec c -> Compat.liftToJSON (`go` c) (`go` listCodec c) (a :: HashMap _ _)+      MapCodec c -> Compat.liftToJSON (`go` c) (`go` listCodec c) (a :: Map _ _)       ValueCodec -> (a :: JSON.Value)       EqCodec value c -> go value c       BimapCodec _ g c -> go (g a) c@@ -133,8 +133,8 @@       NumberCodec _ _ -> JSON.scientific (a :: Scientific)       ArrayOfCodec _ c -> JSON.list (`go` c) (V.toList (a :: Vector _))       ObjectOfCodec _ oc -> JSON.pairs (toSeriesVia oc a)-      HashMapCodec c -> JSON.liftToEncoding (`go` c) (`go` listCodec c) (a :: HashMap _ _)-      MapCodec c -> JSON.liftToEncoding (`go` c) (`go` listCodec c) (a :: Map _ _)+      HashMapCodec c -> Compat.liftToEncoding (`go` c) (`go` listCodec c) (a :: HashMap _ _)+      MapCodec c -> Compat.liftToEncoding (`go` c) (`go` listCodec c) (a :: Map _ _)       ValueCodec -> JSON.value (a :: JSON.Value)       EqCodec value c -> go value c       BimapCodec _ g c -> go (g a) c