forest 0.1 → 0.1.1.1
raw patch · 2 files changed
+39/−16 lines, 2 filesdep ~aesonPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: aeson
API changes (from Hackage documentation)
+ Data.Tree.Forest: instance Data.Aeson.Types.FromJSON.FromJSON (Data.Tree.Forest.Forest f s a) => Data.Aeson.Types.FromJSON.FromJSONKey (Data.Tree.Forest.Forest f s a)
+ Data.Tree.Forest: instance Data.Aeson.Types.FromJSON.FromJSON (Data.Tree.Forest.Tree f s a) => Data.Aeson.Types.FromJSON.FromJSONKey (Data.Tree.Forest.Tree f s a)
+ Data.Tree.Forest: instance Data.Aeson.Types.ToJSON.ToJSON (Data.Tree.Forest.Forest f s a) => Data.Aeson.Types.ToJSON.ToJSONKey (Data.Tree.Forest.Forest f s a)
+ Data.Tree.Forest: instance Data.Aeson.Types.ToJSON.ToJSON (Data.Tree.Forest.Tree f s a) => Data.Aeson.Types.ToJSON.ToJSONKey (Data.Tree.Forest.Tree f s a)
Files
- forest.cabal +2/−2
- src/Data/Tree/Forest.hs +37/−14
forest.cabal view
@@ -1,5 +1,5 @@ name: forest-version: 0.1+version: 0.1.1.1 synopsis: Tree and Forest types license: MPL-2.0 license-file: LICENSE@@ -24,7 +24,7 @@ Data.Tree.Forest build-depends:- aeson >= 0.2 && < 1.2,+ aeson >= 0.2 && < 1.3, base >= 4.2 && < 5, deepseq >= 1.1 && < 2, hashable >= 1.2 && < 2,
src/Data/Tree/Forest.hs view
@@ -54,6 +54,9 @@ , parseJSON , toJSON )+#if MIN_VERSION_aeson(1, 0, 0)+import Data.Aeson.Types (FromJSONKey, ToJSONKey)+#endif -- base ----------------------------------------------------------------------@@ -285,6 +288,18 @@ ------------------------------------------------------------------------------+instance (FromJSON s, FromJSON a, FromJSON (f (Tree f s a))) =>+ FromJSON (Tree f s a)+ where+ parseJSON (Object o) = msum+ [ Node <$> o .: "value" <*> o .: "children"+ , Leaf <$> o .: "value"+ ]+ parseJSON _ = empty+ {-# INLINE parseJSON #-}+++------------------------------------------------------------------------------ instance (ToJSON s, ToJSON a, ToJSON (f (Tree f s a))) => ToJSON (Tree f s a) where@@ -298,19 +313,17 @@ {-# INLINE toJSON #-} +#if MIN_VERSION_aeson(1, 0, 0) -------------------------------------------------------------------------------instance (FromJSON s, FromJSON a, FromJSON (f (Tree f s a))) =>- FromJSON (Tree f s a)- where- parseJSON (Object o) = msum- [ Node <$> o .: "value" <*> o .: "children"- , Leaf <$> o .: "value"- ]- parseJSON _ = empty- {-# INLINE parseJSON #-}+instance FromJSON (Tree f s a) => FromJSONKey (Tree f s a) ------------------------------------------------------------------------------+instance ToJSON (Tree f s a) => ToJSONKey (Tree f s a)+++#endif+------------------------------------------------------------------------------ instance Eq1 f => Eq2 (Tree f) where liftEq2 _ eqa (Leaf a) (Leaf b) = eqa a b liftEq2 eqs eqa (Node s ts) (Node t tt) = and@@ -566,6 +579,14 @@ ------------------------------------------------------------------------------+instance (FromJSON s, FromJSON a, FromJSON (f (Tree f s a))) =>+ FromJSON (Forest f s a)+ where+ parseJSON = fmap Forest . parseJSON+ {-# INLINE parseJSON #-}+++------------------------------------------------------------------------------ instance (ToJSON s, ToJSON a, ToJSON (f (Tree f s a))) => ToJSON (Forest f s a) where@@ -573,14 +594,16 @@ {-# INLINE toJSON #-} +#if MIN_VERSION_aeson(1, 0, 0) -------------------------------------------------------------------------------instance (FromJSON s, FromJSON a, FromJSON (f (Tree f s a))) =>- FromJSON (Forest f s a)- where- parseJSON = fmap Forest . parseJSON- {-# INLINE parseJSON #-}+instance FromJSON (Forest f s a) => FromJSONKey (Forest f s a) +------------------------------------------------------------------------------+instance ToJSON (Forest f s a) => ToJSONKey (Forest f s a)+++#endif ------------------------------------------------------------------------------ instance Eq1 f => Eq2 (Forest f) where liftEq2 eqs eqa (Forest ts) (Forest tt) = liftEq (liftEq2 eqs eqa) ts tt