aeson-generic-default 0.1.0.0 → 0.1.1.0
raw patch · 3 files changed
+16/−7 lines, 3 filesdep ~basePVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: base
API changes (from Hackage documentation)
- Data.Aeson.DefaultField: parseWithDefaults :: forall (o :: ParseStage -> Type) x. (GFromJSON Zero (Rep (o InsertDefaults)), Generic (o InsertDefaults), Generic (o Final), Coercible (Rep (o InsertDefaults) x) (Rep (o Final) x)) => Options -> Value -> Parser (o Final)
+ Data.Aeson.DefaultField: parseWithDefaults :: forall (o :: ParseStage -> Type). (GFromJSON Zero (Rep (o InsertDefaults)), Generic (o InsertDefaults), Generic (o Final), Coercible (Rep (o InsertDefaults)) (Rep (o Final))) => Options -> Value -> Parser (o Final)
Files
- CHANGELOG.md +5/−0
- aeson-generic-default.cabal +2/−2
- src/Data/Aeson/DefaultField.hs +9/−5
CHANGELOG.md view
@@ -1,5 +1,10 @@ # Revision history for aeson-default-field +## 0.1.1.0 -- 2024-10-09++* Simplified signature of parseWithDefaults++ ## 0.1.0.0 -- 2024-10-08 * First version. Released on an unsuspecting world.
aeson-generic-default.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: aeson-generic-default-version: 0.1.0.0+version: 0.1.1.0 synopsis: Type-level default fields for aeson Generic FromJSON parser description: Define default values for missing FromJSON object fields within field type declaration. @@ -56,7 +56,7 @@ import: warnings, extensions exposed-modules: Data.Aeson.DefaultField build-depends: - base >=4.16 && < 4.21,+ base >=4.16 && < 5, aeson >= 2.2 && < 2.3, data-default >= 0.7 && < 0.8, text >= 2.0 && < 2.2
src/Data/Aeson/DefaultField.hs view
@@ -134,15 +134,19 @@ type EmbeddedType (D1 d (C1 c (S1 s (K1 i a)))) = a -- | 'genericParseJSON' drop-in replacement-parseWithDefaults :: forall (o :: ParseStage -> Type) x. +parseWithDefaults :: forall (o :: ParseStage -> Type). (AE.GFromJSON AE.Zero (Rep (o InsertDefaults)) , Generic (o InsertDefaults), Generic (o Final)- , Coercible (Rep (o InsertDefaults) x) (Rep (o Final) x)+ , Coercible (Rep (o InsertDefaults)) (Rep (o Final)) ) => AE.Options -> AE.Value -> Parser (o Final)-parseWithDefaults opts v = do- (dx :: o InsertDefaults) <- genericParseJSON opts v- return $ to @_ @x (coerce (from @_ @x dx))+parseWithDefaults opts v =+ gcoerce <$> genericParseJSON @(o InsertDefaults) opts v+ where+ -- Taken from generic-data+ gcoerce = to . coerce1 . from+ coerce1 :: Coercible f g => f x -> g x+ coerce1 = coerce -- $use --