json-sop 0.2.0.4 → 0.2.0.5
raw patch · 3 files changed
+36/−6 lines, 3 filesdep ~aesonnew-uploaderPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: aeson
API changes (from Hackage documentation)
- Generics.SOP.JSON: data Proxy (t :: k) :: forall k. () => k -> Type
- Generics.SOP.JSON.Model: newtype Tagged (s :: k) b :: forall k. () => k -> Type -> Type
+ Generics.SOP.JSON: data Proxy (t :: k)
+ Generics.SOP.JSON.Model: newtype Tagged (s :: k) b
- Generics.SOP.JSON: Proxy :: Proxy
+ Generics.SOP.JSON: Proxy :: Proxy (t :: k)
- Generics.SOP.JSON.Model: Tagged :: b -> Tagged b
+ Generics.SOP.JSON.Model: Tagged :: b -> Tagged (s :: k) b
- Generics.SOP.JSON.Model: [unTagged] :: Tagged b -> b
+ Generics.SOP.JSON.Model: [unTagged] :: Tagged (s :: k) b -> b
- Generics.SOP.JSON.Model: untag :: () => Tagged s b -> b
+ Generics.SOP.JSON.Model: untag :: forall k (s :: k) b. Tagged s b -> b
Files
- json-sop.cabal +4/−4
- src/Generics/SOP/JSON.hs +25/−0
- src/Generics/SOP/Util/PartialResult.hs +7/−2
json-sop.cabal view
@@ -1,5 +1,5 @@ name: json-sop-version: 0.2.0.4+version: 0.2.0.5 synopsis: Generics JSON (de)serialization using generics-sop description: This library contains generic serialization and deserialization functions@@ -13,7 +13,7 @@ category: Generics build-type: Simple cabal-version: >=1.10-tested-with: GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.4, GHC == 8.6.5+tested-with: GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.4, GHC == 8.6.5, GHC == 8.8.4, GHC == 8.10.2 source-repository head type: git@@ -27,7 +27,7 @@ generics-sop >= 0.2.3 && < 0.6, lens-sop >= 0.2 && < 0.3, tagged >= 0.7 && < 0.9,- aeson >= 0.7 && < 1.5,+ aeson >= 0.7 && < 1.6, vector >= 0.10 && < 0.13, text >= 1.1 && < 1.3, unordered-containers >= 0.2 && < 0.3,@@ -54,7 +54,7 @@ DataKinds FunctionalDependencies CPP- if impl (ghc >= 7.8)+ if impl (ghc >= 7.8) && impl (ghc < 8.2) default-extensions: AutoDeriveTypeable other-extensions: OverloadedStrings PolyKinds
src/Generics/SOP/JSON.hs view
@@ -352,8 +352,13 @@ -- -- The first form is useful when all fields of a record need to be present; -- the second when they are optional.+#if MIN_VERSION_base(4,13,0)+lineup :: (MonadFail m, MonadPlus m', MonadFail m', Eq a, Show a)+ => NP (K a) xs -> [(a, b)] -> m (NP (K (m' b)) xs)+#else lineup :: (Monad m, MonadPlus m', Eq a, Show a) => NP (K a) xs -> [(a, b)] -> m (NP (K (m' b)) xs)+#endif lineup Nil [] = return Nil lineup Nil vals = fail $ "Unexpected key(s): " ++ show (map fst vals) lineup (K k :* ks) [] = do bs <- lineup ks [] ; return $ K (missingKey k) :* bs@@ -363,7 +368,11 @@ Just ((_, b), vs') -> do bs <- lineup ks vs' ; return $ K (return b) :* bs -- | Error message for a missing key (used in lineup)+#if MIN_VERSION_base(4,13,0)+missingKey :: (MonadFail m, Show a) => a -> m b+#else missingKey :: (Monad m, Show a) => a -> m b+#endif missingKey k = fail $ "missing key " ++ show k -- | Remove the first element that satisfies the predicate@@ -399,19 +408,35 @@ Adaptation of some of Aeson's combinators -------------------------------------------------------------------------------} +#if MIN_VERSION_base(4,13,0)+withObject :: MonadFail m => String -> ([(String, Value)] -> m a) -> Value -> m a+#else withObject :: Monad m => String -> ([(String, Value)] -> m a) -> Value -> m a+#endif withObject _ f (Object obj) = f $ map (first Text.unpack) (HashMap.toList obj) withObject expected _ v = typeMismatch expected v +#if MIN_VERSION_base(4,13,0)+withText :: MonadFail m => String -> (Text -> m a) -> Value -> m a+#else withText :: Monad m => String -> (Text -> m a) -> Value -> m a+#endif withText _ f (String txt) = f txt withText expected _ v = typeMismatch expected v +#if MIN_VERSION_base(4,13,0)+withArray :: MonadFail m => String -> ([Value] -> m a) -> Value -> m a+#else withArray :: Monad m => String -> ([Value] -> m a) -> Value -> m a+#endif withArray _ f (Array arr) = f $ Vector.toList arr withArray expected _ v = typeMismatch expected v +#if MIN_VERSION_base(4,13,0)+typeMismatch :: MonadFail m+#else typeMismatch :: Monad m+#endif => String -- ^ The name of the type you are trying to parse. -> Value -- ^ The actual value encountered. -> m a
src/Generics/SOP/Util/PartialResult.hs view
@@ -37,12 +37,19 @@ instance Functor f => Monad (Partial f) where return = PZero+#if !MIN_VERSION_base(4,13,0) fail = Fail . return+#endif Fail e >>= _ = Fail e PZero a >>= f = f a PSucc fa >>= f = PSucc (fmap (>>= f) fa) +#if MIN_VERSION_base(4,13,0)+instance Functor f => MonadFail (Partial f) where+ fail = Fail . return+#endif+ instance (MonadPlus f, Functor f) => MonadPlus (Partial f) where mzero = Fail [] @@ -72,5 +79,3 @@ go (PZero a) = return a go (PSucc fa) = fa >>= go go (Fail es) = failWith es--