-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Apply a json-patch to any haskell datatype. -- -- Apply a json-patch directly to a haskell datatype. It extends the -- capabilities of the aeson-diff packages, and includes template haskell -- functions for automatically deriving the right instances. @package aeson-diff-generic @version 0.0.3 module Data.Aeson.Diff.Generic.PathOptics type PathLens s a = Lens' (Path, s) (Path, a) type PathTraversal s a = Traversal' (Path, s) (Path, a) -- | Modify the value(s) at the traversal, and return a patch which -- represents those (replace) operations. overPath :: ToJSON a => PathTraversal s a -> (a -> a) -> s -> (Patch, s) -- | Replace the value at the traversal, and return a patch with the -- replace operations. replacePath :: ToJSON a => PathTraversal s a -> a -> s -> (Patch, s) -- | Return the values and pointers pointed to by the traversal (if any) getPath :: PathTraversal s a -> s -> [(Pointer, a)] -- | Append a value to the structure pointed by the lens. Return a patch -- which the append operations) appendPath :: (ToJSON (IxValue a), Appendable a) => IxValue a -> PathTraversal s a -> s -> (Patch, s) -- | Insert a value at the given key, and return a patch with the insert -- operations insertPath :: (ToJSON (IxValue a), Insertable a) => Index a -> IxValue a -> PathTraversal s a -> s -> (Patch, s) -- | Delete a value at the given key if present, and return a patch with -- the delete operations. deletePath :: (ToJSON (IxValue a), Insertable a) => Index a -> PathTraversal s a -> s -> (Patch, s) -- | Create a patch that tests if the value at the pointer equals the -- current value. Returns the data unmodified. testPath :: ToJSON a => PathTraversal s a -> s -> (Patch, s) class KeyIndexed s toKey :: KeyIndexed s => Index s -> s -> Key class KeyIndexed a => Insertable a insertKey :: Insertable a => Index a -> (IxValue a) -> a -> a deleteKey :: Insertable a => Index a -> a -> Maybe (IxValue a, a) class KeyIndexed a => Appendable a append :: Appendable a => (IxValue a) -> a -> a -- | Annotate an optic with a path. The output optic will be the same -- optic, with a path annotation. For example: -- --
--   withPath :: Path -> Lens' s a -> Lens' (Path, s) (Path, a)
--   withPath :: Path -> Traversal' s a -> Traversal' (Path, s) (Path, a)
--   
withPath :: Functor f => Path -> ((a -> Compose f ((,) Path) a) -> (s -> Compose f ((,) Path) s)) -> (((Path, a) -> f (Path, a)) -> (Path, s) -> f (Path, s)) -- | remove the path from an optic annotated with path information. -- --
--   withoutPath . withPath ≡ id
--   
-- -- The output optic will be the same optic, without the path annotation. -- For example: -- --
--   withoutPath ::  Lens' (Path, s) (Path, a) -> Lens' s a
--   withoutPath :: Traversal' (Path, s) (Path, a) -> Traversal' s a
--   
withoutPath :: Functor f => (((Path, a) -> f (Path, a)) -> ((Path, s) -> f (Path, s))) -> ((a -> f a) -> (s -> f s)) -- | ix from lens annotated with a path. Provides a simple Traversal -- lets you traverse the value at a given key in a Map or element at an -- ordinal position in a list or Seq. Includes the path to the element. ixP :: (KeyIndexed s, Ixed s) => Index s -> Traversal' (Path, s) (Path, IxValue s) traverseP :: (a ~ Index (s a), TraversableWithIndex a s, KeyIndexed (s a)) => Traversal' (Path, (s a)) (Path, a) _1P :: Field1 s s a a => PathLens s a _2P :: Field2 s s a a => PathLens s a _3P :: Field3 s s a a => PathLens s a _4P :: Field4 s s a a => PathLens s a _5P :: Field5 s s a a => PathLens s a _6P :: Field6 s s a a => PathLens s a _7P :: Field7 s s a a => PathLens s a _8P :: Field8 s s a a => PathLens s a _9P :: Field9 s s a a => PathLens s a _10P :: Field10 s s a a => PathLens s a _11P :: Field11 s s a a => PathLens s a _12P :: Field12 s s a a => PathLens s a _13P :: Field13 s s a a => PathLens s a _14P :: Field14 s s a a => PathLens s a _15P :: Field15 s s a a => PathLens s a _16P :: Field16 s s a a => PathLens s a _17P :: Field17 s s a a => PathLens s a _18P :: Field18 s s a a => PathLens s a _19P :: Field19 s s a a => PathLens s a _LeftP :: Traversal' (Path, Either a b) (Path, a) _RightP :: Traversal' (Path, Either a b) (Path, b) _JustP :: Traversal' (Path, Maybe a) (Path, a) -- | This module contains functions to automatically derive -- JsonPatch instances. module Data.Aeson.Diff.Generic.TH -- | Derive a JsonPatch instance, using the given aeson Options. -- This should work with a ToJSON and FromJSON instance -- that uses the same options. deriveJsonPatch :: Options -> Name -> DecsQ -- | Instances are put into this module to avoid circular dependencies with -- the TH module. There is no need to import this module, since it is -- already re-exported in Data.Aeson.Diff.Generic. This module is -- only exported for documentation purpose. module Data.Aeson.Diff.Generic.Instances instance Data.Aeson.Diff.Generic.Types.JsonPatch a => Data.Aeson.Diff.Generic.Types.JsonPatch (Data.Semigroup.Min a) instance Data.Aeson.Diff.Generic.Types.JsonPatch a => Data.Aeson.Diff.Generic.Types.JsonPatch (Data.Semigroup.Max a) instance Data.Aeson.Diff.Generic.Types.JsonPatch a => Data.Aeson.Diff.Generic.Types.JsonPatch (Data.Semigroup.First a) instance Data.Aeson.Diff.Generic.Types.JsonPatch a => Data.Aeson.Diff.Generic.Types.JsonPatch (Data.Semigroup.Last a) instance Data.Aeson.Diff.Generic.Types.JsonPatch a => Data.Aeson.Diff.Generic.Types.JsonPatch (Data.Semigroup.WrappedMonoid a) instance Data.Aeson.Diff.Generic.Types.JsonPatch a => Data.Aeson.Diff.Generic.Types.JsonPatch (Data.Semigroup.Option a) instance Data.Aeson.Diff.Generic.Types.JsonPatch a => Data.Aeson.Diff.Generic.Types.JsonPatch (Data.Functor.Identity.Identity a) instance Data.Aeson.Diff.Generic.Types.JsonPatch a => Data.Aeson.Diff.Generic.Types.JsonPatch (Data.Monoid.Dual a) instance (Data.Typeable.Internal.Typeable b, Data.Aeson.Diff.Generic.Types.JsonPatch a) => Data.Aeson.Diff.Generic.Types.JsonPatch (Data.Functor.Const.Const a b) instance (Data.Functor.Classes.Eq1 f, Data.Functor.Classes.Eq1 g, Data.Aeson.Types.FromJSON.FromJSON1 f, Data.Aeson.Types.FromJSON.FromJSON1 g, Data.Typeable.Internal.Typeable f, Data.Typeable.Internal.Typeable g, Data.Aeson.Diff.Generic.Types.JsonPatch a, Data.Aeson.Types.ToJSON.ToJSON1 f, Data.Aeson.Types.ToJSON.ToJSON1 g, Data.Aeson.Diff.Generic.Types.JsonPatch (f (g a))) => Data.Aeson.Diff.Generic.Types.JsonPatch (Data.Functor.Compose.Compose f g a) instance (Data.Typeable.Internal.Typeable a, Data.Aeson.Diff.Generic.Types.JsonPatch b) => Data.Aeson.Diff.Generic.Types.JsonPatch (Data.Tagged.Tagged a b) instance (Data.Aeson.Diff.Generic.Types.JsonPatch a1, Data.Aeson.Diff.Generic.Types.JsonPatch a2, Data.Aeson.Diff.Generic.Types.JsonPatch a3, Data.Aeson.Diff.Generic.Types.JsonPatch a4, Data.Aeson.Diff.Generic.Types.JsonPatch a5, Data.Aeson.Diff.Generic.Types.JsonPatch a6, Data.Aeson.Diff.Generic.Types.JsonPatch a7, Data.Aeson.Diff.Generic.Types.JsonPatch a8, Data.Aeson.Diff.Generic.Types.JsonPatch a9, Data.Aeson.Diff.Generic.Types.JsonPatch a10, Data.Aeson.Diff.Generic.Types.JsonPatch a11, Data.Aeson.Diff.Generic.Types.JsonPatch a12, Data.Aeson.Diff.Generic.Types.JsonPatch a13, Data.Aeson.Diff.Generic.Types.JsonPatch a14, Data.Aeson.Diff.Generic.Types.JsonPatch a15) => Data.Aeson.Diff.Generic.Types.JsonPatch (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15) instance Data.Typeable.Internal.Typeable a => Data.Aeson.Diff.Generic.Types.JsonPatch (Data.Proxy.Proxy a) instance Data.Aeson.Diff.Generic.Types.JsonPatch a => Data.Aeson.Diff.Generic.Types.JsonPatch (Data.Tree.Tree a) instance Data.Aeson.Diff.Generic.Types.JsonPatch a => Data.Aeson.Diff.Generic.Types.FieldLens (Data.Tree.Tree a) instance (Data.Aeson.Types.ToJSON.ToJSON1 f, Data.Aeson.Types.ToJSON.ToJSON1 g, Data.Aeson.Types.FromJSON.FromJSON1 f, Data.Aeson.Types.FromJSON.FromJSON1 g, Data.Functor.Classes.Eq1 f, Data.Functor.Classes.Eq1 g, Data.Aeson.Diff.Generic.Types.JsonPatch a, Data.Typeable.Internal.Typeable f, Data.Typeable.Internal.Typeable g, Data.Aeson.Diff.Generic.Types.JsonPatch (f a), Data.Aeson.Diff.Generic.Types.JsonPatch (g a)) => Data.Aeson.Diff.Generic.Types.JsonPatch (Data.Functor.Product.Product f g a) instance (Data.Aeson.Types.ToJSON.ToJSON1 f, Data.Aeson.Types.ToJSON.ToJSON1 g, Data.Aeson.Types.FromJSON.FromJSON1 f, Data.Aeson.Types.FromJSON.FromJSON1 g, Data.Functor.Classes.Eq1 f, Data.Functor.Classes.Eq1 g, Data.Aeson.Diff.Generic.Types.JsonPatch a, Data.Typeable.Internal.Typeable f, Data.Typeable.Internal.Typeable g, Data.Aeson.Diff.Generic.Types.JsonPatch (f a), Data.Aeson.Diff.Generic.Types.JsonPatch (g a)) => Data.Aeson.Diff.Generic.Types.FieldLens (Data.Functor.Product.Product f g a) instance (Data.Aeson.Types.ToJSON.ToJSON1 f, Data.Aeson.Types.ToJSON.ToJSON1 g, Data.Aeson.Types.FromJSON.FromJSON1 f, Data.Aeson.Types.FromJSON.FromJSON1 g, Data.Functor.Classes.Eq1 f, Data.Functor.Classes.Eq1 g, Data.Aeson.Diff.Generic.Types.JsonPatch a, Data.Typeable.Internal.Typeable f, Data.Typeable.Internal.Typeable g, Data.Aeson.Diff.Generic.Types.JsonPatch (f a), Data.Aeson.Diff.Generic.Types.JsonPatch (g a)) => Data.Aeson.Diff.Generic.Types.JsonPatch (Data.Functor.Sum.Sum f g a) instance (Data.Aeson.Types.ToJSON.ToJSON1 f, Data.Aeson.Types.ToJSON.ToJSON1 g, Data.Aeson.Types.FromJSON.FromJSON1 f, Data.Aeson.Types.FromJSON.FromJSON1 g, Data.Functor.Classes.Eq1 f, Data.Functor.Classes.Eq1 g, Data.Aeson.Diff.Generic.Types.JsonPatch a, Data.Typeable.Internal.Typeable f, Data.Typeable.Internal.Typeable g, Data.Aeson.Diff.Generic.Types.JsonPatch (f a), Data.Aeson.Diff.Generic.Types.JsonPatch (g a)) => Data.Aeson.Diff.Generic.Types.FieldLens (Data.Functor.Sum.Sum f g a) instance Data.Aeson.Diff.Generic.Types.JsonPatch a => Data.Aeson.Diff.Generic.Types.JsonPatch [a] instance Data.Aeson.Diff.Generic.Types.JsonPatch a => Data.Aeson.Diff.Generic.Types.FieldLens [a] instance Data.Aeson.Diff.Generic.Types.JsonPatch a => Data.Aeson.Diff.Generic.Types.JsonPatch (Data.List.NonEmpty.NonEmpty a) instance Data.Aeson.Diff.Generic.Types.JsonPatch a => Data.Aeson.Diff.Generic.Types.FieldLens (Data.List.NonEmpty.NonEmpty a) instance Data.Aeson.Diff.Generic.Types.JsonPatch a => Data.Aeson.Diff.Generic.Types.JsonPatch (Data.DList.DList a) instance Data.Aeson.Diff.Generic.Types.JsonPatch a => Data.Aeson.Diff.Generic.Types.FieldLens (Data.DList.DList a) instance (GHC.Classes.Ord a, Data.Aeson.Diff.Generic.Types.JsonPatch a) => Data.Aeson.Diff.Generic.Types.JsonPatch (Data.Set.Internal.Set a) instance (GHC.Classes.Ord a, Data.Aeson.Diff.Generic.Types.JsonPatch a) => Data.Aeson.Diff.Generic.Types.FieldLens (Data.Set.Internal.Set a) instance (GHC.Classes.Ord a, Data.Aeson.Diff.Generic.Types.JsonPatch a) => Data.Aeson.Diff.Generic.Types.JsonPatch (Data.Sequence.Internal.Seq a) instance (GHC.Classes.Ord a, Data.Aeson.Diff.Generic.Types.JsonPatch a) => Data.Aeson.Diff.Generic.Types.FieldLens (Data.Sequence.Internal.Seq a) instance Data.Aeson.Diff.Generic.Types.JsonPatch a => Data.Aeson.Diff.Generic.Types.FieldLens (Data.Vector.Vector a) instance (Data.Vector.Unboxed.Base.Unbox a, Data.Aeson.Diff.Generic.Types.JsonPatch a) => Data.Aeson.Diff.Generic.Types.JsonPatch (Data.Vector.Unboxed.Base.Vector a) instance (Data.Vector.Unboxed.Base.Unbox a, Data.Aeson.Diff.Generic.Types.JsonPatch a) => Data.Aeson.Diff.Generic.Types.FieldLens (Data.Vector.Unboxed.Base.Vector a) instance (Foreign.Storable.Storable a, Data.Aeson.Diff.Generic.Types.JsonPatch a) => Data.Aeson.Diff.Generic.Types.JsonPatch (Data.Vector.Storable.Vector a) instance (Foreign.Storable.Storable a, Data.Aeson.Diff.Generic.Types.JsonPatch a) => Data.Aeson.Diff.Generic.Types.FieldLens (Data.Vector.Storable.Vector a) instance (Data.Primitive.Types.Prim a, Data.Aeson.Diff.Generic.Types.JsonPatch a) => Data.Aeson.Diff.Generic.Types.JsonPatch (Data.Vector.Primitive.Vector a) instance (Data.Primitive.Types.Prim a, Data.Aeson.Diff.Generic.Types.JsonPatch a) => Data.Aeson.Diff.Generic.Types.FieldLens (Data.Vector.Primitive.Vector a) instance (Data.Aeson.Types.ToJSON.ToJSONKey k, Data.Typeable.Internal.Typeable k, GHC.Classes.Eq k, Data.Hashable.Class.Hashable k, Data.Aeson.Types.FromJSON.FromJSONKey k, Data.Aeson.Diff.Generic.Types.JsonPatch a) => Data.Aeson.Diff.Generic.Types.JsonPatch (Data.HashMap.Base.HashMap k a) instance (Data.Aeson.Types.ToJSON.ToJSONKey k, Data.Typeable.Internal.Typeable k, GHC.Classes.Eq k, Data.Hashable.Class.Hashable k, Data.Aeson.Types.FromJSON.FromJSONKey k, Data.Aeson.Diff.Generic.Types.JsonPatch a) => Data.Aeson.Diff.Generic.Types.FieldLens (Data.HashMap.Base.HashMap k a) instance (Data.Aeson.Types.FromJSON.FromJSONKey k, Data.Aeson.Types.ToJSON.ToJSONKey k, GHC.Classes.Eq k, GHC.Classes.Ord k, Data.Aeson.Diff.Generic.Types.JsonPatch k, Data.Aeson.Diff.Generic.Types.JsonPatch a) => Data.Aeson.Diff.Generic.Types.JsonPatch (Data.Map.Internal.Map k a) instance (Data.Aeson.Types.FromJSON.FromJSONKey k, Data.Aeson.Types.ToJSON.ToJSONKey k, GHC.Classes.Eq k, GHC.Classes.Ord k, Data.Aeson.Diff.Generic.Types.JsonPatch a, Data.Aeson.Diff.Generic.Types.JsonPatch k) => Data.Aeson.Diff.Generic.Types.FieldLens (Data.Map.Internal.Map k a) instance Data.Aeson.Diff.Generic.Types.JsonPatch Data.Aeson.Types.Internal.Value instance (Data.Aeson.Diff.Generic.Types.JsonPatch a1, Data.Aeson.Diff.Generic.Types.JsonPatch a2, Data.Aeson.Diff.Generic.Types.JsonPatch a3, Data.Aeson.Diff.Generic.Types.JsonPatch a4, Data.Aeson.Diff.Generic.Types.JsonPatch a5, Data.Aeson.Diff.Generic.Types.JsonPatch a6, Data.Aeson.Diff.Generic.Types.JsonPatch a7, Data.Aeson.Diff.Generic.Types.JsonPatch a8, Data.Aeson.Diff.Generic.Types.JsonPatch a9, Data.Aeson.Diff.Generic.Types.JsonPatch a10, Data.Aeson.Diff.Generic.Types.JsonPatch a11, Data.Aeson.Diff.Generic.Types.JsonPatch a12, Data.Aeson.Diff.Generic.Types.JsonPatch a13, Data.Aeson.Diff.Generic.Types.JsonPatch a14) => Data.Aeson.Diff.Generic.Types.JsonPatch (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14) instance (Data.Aeson.Diff.Generic.Types.JsonPatch a1, Data.Aeson.Diff.Generic.Types.JsonPatch a2, Data.Aeson.Diff.Generic.Types.JsonPatch a3, Data.Aeson.Diff.Generic.Types.JsonPatch a4, Data.Aeson.Diff.Generic.Types.JsonPatch a5, Data.Aeson.Diff.Generic.Types.JsonPatch a6, Data.Aeson.Diff.Generic.Types.JsonPatch a7, Data.Aeson.Diff.Generic.Types.JsonPatch a8, Data.Aeson.Diff.Generic.Types.JsonPatch a9, Data.Aeson.Diff.Generic.Types.JsonPatch a10, Data.Aeson.Diff.Generic.Types.JsonPatch a11, Data.Aeson.Diff.Generic.Types.JsonPatch a12, Data.Aeson.Diff.Generic.Types.JsonPatch a13) => Data.Aeson.Diff.Generic.Types.JsonPatch (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13) instance (Data.Aeson.Diff.Generic.Types.JsonPatch a1, Data.Aeson.Diff.Generic.Types.JsonPatch a2, Data.Aeson.Diff.Generic.Types.JsonPatch a3, Data.Aeson.Diff.Generic.Types.JsonPatch a4, Data.Aeson.Diff.Generic.Types.JsonPatch a5, Data.Aeson.Diff.Generic.Types.JsonPatch a6, Data.Aeson.Diff.Generic.Types.JsonPatch a7, Data.Aeson.Diff.Generic.Types.JsonPatch a8, Data.Aeson.Diff.Generic.Types.JsonPatch a9, Data.Aeson.Diff.Generic.Types.JsonPatch a10, Data.Aeson.Diff.Generic.Types.JsonPatch a11, Data.Aeson.Diff.Generic.Types.JsonPatch a12) => Data.Aeson.Diff.Generic.Types.JsonPatch (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) instance (Data.Aeson.Diff.Generic.Types.JsonPatch a1, Data.Aeson.Diff.Generic.Types.JsonPatch a2, Data.Aeson.Diff.Generic.Types.JsonPatch a3, Data.Aeson.Diff.Generic.Types.JsonPatch a4, Data.Aeson.Diff.Generic.Types.JsonPatch a5, Data.Aeson.Diff.Generic.Types.JsonPatch a6, Data.Aeson.Diff.Generic.Types.JsonPatch a7, Data.Aeson.Diff.Generic.Types.JsonPatch a8, Data.Aeson.Diff.Generic.Types.JsonPatch a9, Data.Aeson.Diff.Generic.Types.JsonPatch a10, Data.Aeson.Diff.Generic.Types.JsonPatch a11) => Data.Aeson.Diff.Generic.Types.JsonPatch (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11) instance (Data.Aeson.Diff.Generic.Types.JsonPatch a1, Data.Aeson.Diff.Generic.Types.JsonPatch a2, Data.Aeson.Diff.Generic.Types.JsonPatch a3, Data.Aeson.Diff.Generic.Types.JsonPatch a4, Data.Aeson.Diff.Generic.Types.JsonPatch a5, Data.Aeson.Diff.Generic.Types.JsonPatch a6, Data.Aeson.Diff.Generic.Types.JsonPatch a7, Data.Aeson.Diff.Generic.Types.JsonPatch a8, Data.Aeson.Diff.Generic.Types.JsonPatch a9, Data.Aeson.Diff.Generic.Types.JsonPatch a10) => Data.Aeson.Diff.Generic.Types.JsonPatch (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) instance (Data.Aeson.Diff.Generic.Types.JsonPatch a1, Data.Aeson.Diff.Generic.Types.JsonPatch a2, Data.Aeson.Diff.Generic.Types.JsonPatch a3, Data.Aeson.Diff.Generic.Types.JsonPatch a4, Data.Aeson.Diff.Generic.Types.JsonPatch a5, Data.Aeson.Diff.Generic.Types.JsonPatch a6, Data.Aeson.Diff.Generic.Types.JsonPatch a7, Data.Aeson.Diff.Generic.Types.JsonPatch a8, Data.Aeson.Diff.Generic.Types.JsonPatch a9) => Data.Aeson.Diff.Generic.Types.JsonPatch (a1, a2, a3, a4, a5, a6, a7, a8, a9) instance (Data.Aeson.Diff.Generic.Types.JsonPatch a1, Data.Aeson.Diff.Generic.Types.JsonPatch a2, Data.Aeson.Diff.Generic.Types.JsonPatch a3, Data.Aeson.Diff.Generic.Types.JsonPatch a4, Data.Aeson.Diff.Generic.Types.JsonPatch a5, Data.Aeson.Diff.Generic.Types.JsonPatch a6, Data.Aeson.Diff.Generic.Types.JsonPatch a7, Data.Aeson.Diff.Generic.Types.JsonPatch a8) => Data.Aeson.Diff.Generic.Types.JsonPatch (a1, a2, a3, a4, a5, a6, a7, a8) instance (Data.Aeson.Diff.Generic.Types.JsonPatch a1, Data.Aeson.Diff.Generic.Types.JsonPatch a2, Data.Aeson.Diff.Generic.Types.JsonPatch a3, Data.Aeson.Diff.Generic.Types.JsonPatch a4, Data.Aeson.Diff.Generic.Types.JsonPatch a5, Data.Aeson.Diff.Generic.Types.JsonPatch a6, Data.Aeson.Diff.Generic.Types.JsonPatch a7) => Data.Aeson.Diff.Generic.Types.JsonPatch (a1, a2, a3, a4, a5, a6, a7) instance (Data.Aeson.Diff.Generic.Types.JsonPatch a1, Data.Aeson.Diff.Generic.Types.JsonPatch a2, Data.Aeson.Diff.Generic.Types.JsonPatch a3, Data.Aeson.Diff.Generic.Types.JsonPatch a4, Data.Aeson.Diff.Generic.Types.JsonPatch a5, Data.Aeson.Diff.Generic.Types.JsonPatch a6) => Data.Aeson.Diff.Generic.Types.JsonPatch (a1, a2, a3, a4, a5, a6) instance (Data.Aeson.Diff.Generic.Types.JsonPatch a1, Data.Aeson.Diff.Generic.Types.JsonPatch a2, Data.Aeson.Diff.Generic.Types.JsonPatch a3, Data.Aeson.Diff.Generic.Types.JsonPatch a4, Data.Aeson.Diff.Generic.Types.JsonPatch a5) => Data.Aeson.Diff.Generic.Types.JsonPatch (a1, a2, a3, a4, a5) instance (Data.Aeson.Diff.Generic.Types.JsonPatch a1, Data.Aeson.Diff.Generic.Types.JsonPatch a2, Data.Aeson.Diff.Generic.Types.JsonPatch a3, Data.Aeson.Diff.Generic.Types.JsonPatch a4) => Data.Aeson.Diff.Generic.Types.JsonPatch (a1, a2, a3, a4) instance (Data.Aeson.Diff.Generic.Types.JsonPatch a1, Data.Aeson.Diff.Generic.Types.JsonPatch a2, Data.Aeson.Diff.Generic.Types.JsonPatch a3) => Data.Aeson.Diff.Generic.Types.JsonPatch (a1, a2, a3) instance (Data.Aeson.Diff.Generic.Types.JsonPatch a1, Data.Aeson.Diff.Generic.Types.JsonPatch a2) => Data.Aeson.Diff.Generic.Types.JsonPatch (a1, a2) instance Data.Aeson.Diff.Generic.Types.JsonPatch a => Data.Aeson.Diff.Generic.Types.JsonPatch (GHC.Base.Maybe a) instance (Data.Aeson.Diff.Generic.Types.JsonPatch a1, Data.Aeson.Diff.Generic.Types.JsonPatch a2) => Data.Aeson.Diff.Generic.Types.JsonPatch (Data.Either.Either a1 a2) instance Data.Aeson.Diff.Generic.Types.FieldLens GHC.Types.Bool instance Data.Aeson.Diff.Generic.Types.FieldLens GHC.Types.Char instance Data.Aeson.Diff.Generic.Types.FieldLens GHC.Types.Double instance Data.Aeson.Diff.Generic.Types.FieldLens GHC.Types.Float instance Data.Aeson.Diff.Generic.Types.FieldLens GHC.Types.Int instance Data.Aeson.Diff.Generic.Types.FieldLens GHC.Int.Int8 instance Data.Aeson.Diff.Generic.Types.FieldLens GHC.Int.Int16 instance Data.Aeson.Diff.Generic.Types.FieldLens GHC.Int.Int32 instance Data.Aeson.Diff.Generic.Types.FieldLens GHC.Int.Int64 instance Data.Aeson.Diff.Generic.Types.FieldLens GHC.Integer.Type.Integer instance Data.Aeson.Diff.Generic.Types.FieldLens GHC.Natural.Natural instance Data.Aeson.Diff.Generic.Types.FieldLens GHC.Types.Ordering instance Data.Aeson.Diff.Generic.Types.FieldLens GHC.Types.Word instance Data.Aeson.Diff.Generic.Types.FieldLens GHC.Word.Word8 instance Data.Aeson.Diff.Generic.Types.FieldLens GHC.Word.Word16 instance Data.Aeson.Diff.Generic.Types.FieldLens GHC.Word.Word32 instance Data.Aeson.Diff.Generic.Types.FieldLens GHC.Word.Word64 instance Data.Aeson.Diff.Generic.Types.FieldLens () instance Data.Aeson.Diff.Generic.Types.FieldLens Data.Text.Internal.Text instance Data.Aeson.Diff.Generic.Types.FieldLens Data.Text.Internal.Lazy.Text instance Data.Aeson.Diff.Generic.Types.FieldLens Data.Version.Version instance Data.Aeson.Diff.Generic.Types.FieldLens Foreign.C.Types.CTime instance Data.Aeson.Diff.Generic.Types.FieldLens Data.IntSet.Internal.IntSet instance Data.Aeson.Diff.Generic.Types.FieldLens Data.Scientific.Scientific instance Data.Aeson.Diff.Generic.Types.FieldLens Data.Time.LocalTime.Internal.LocalTime.LocalTime instance Data.Aeson.Diff.Generic.Types.FieldLens Data.Time.LocalTime.Internal.TimeOfDay.TimeOfDay instance Data.Aeson.Diff.Generic.Types.FieldLens Data.Time.Clock.Internal.UTCTime.UTCTime instance Data.Aeson.Diff.Generic.Types.FieldLens Data.Time.Clock.Internal.NominalDiffTime.NominalDiffTime instance Data.Aeson.Diff.Generic.Types.FieldLens Data.Time.Clock.Internal.DiffTime.DiffTime instance Data.Aeson.Diff.Generic.Types.FieldLens Data.Time.Calendar.Days.Day instance Data.Aeson.Diff.Generic.Types.FieldLens Data.UUID.Types.Internal.UUID instance Data.Aeson.Diff.Generic.Types.FieldLens Data.Aeson.Types.Internal.DotNetTime instance (Data.Hashable.Class.Hashable a, GHC.Classes.Eq a, Data.Aeson.Types.FromJSON.FromJSON a, Data.Typeable.Internal.Typeable a, Data.Aeson.Types.ToJSON.ToJSON a) => Data.Aeson.Diff.Generic.Types.FieldLens (Data.HashSet.HashSet a) instance (Data.Typeable.Internal.Typeable a, GHC.Real.Integral a, Data.Aeson.Types.ToJSON.ToJSON a, Data.Aeson.Types.FromJSON.FromJSON a, GHC.Classes.Eq a) => Data.Aeson.Diff.Generic.Types.FieldLens (GHC.Real.Ratio a) instance (Data.Fixed.HasResolution a, Data.Typeable.Internal.Typeable a, Data.Aeson.Types.FromJSON.FromJSON a, Data.Aeson.Types.ToJSON.ToJSON a) => Data.Aeson.Diff.Generic.Types.FieldLens (Data.Fixed.Fixed a) instance Data.Aeson.Diff.Generic.Types.JsonPatch a => Data.Aeson.Diff.Generic.Types.FieldLens (Data.IntMap.Internal.IntMap a) instance Data.Typeable.Internal.Typeable a => Data.Aeson.Diff.Generic.Types.FieldLens (Data.Proxy.Proxy a) instance Data.Aeson.Diff.Generic.Types.JsonPatch GHC.Types.Bool instance Data.Aeson.Diff.Generic.Types.JsonPatch GHC.Types.Char instance Data.Aeson.Diff.Generic.Types.JsonPatch GHC.Types.Double instance Data.Aeson.Diff.Generic.Types.JsonPatch GHC.Types.Float instance Data.Aeson.Diff.Generic.Types.JsonPatch GHC.Types.Int instance Data.Aeson.Diff.Generic.Types.JsonPatch GHC.Int.Int8 instance Data.Aeson.Diff.Generic.Types.JsonPatch GHC.Int.Int16 instance Data.Aeson.Diff.Generic.Types.JsonPatch GHC.Int.Int32 instance Data.Aeson.Diff.Generic.Types.JsonPatch GHC.Int.Int64 instance Data.Aeson.Diff.Generic.Types.JsonPatch GHC.Integer.Type.Integer instance Data.Aeson.Diff.Generic.Types.JsonPatch GHC.Natural.Natural instance Data.Aeson.Diff.Generic.Types.JsonPatch GHC.Types.Ordering instance Data.Aeson.Diff.Generic.Types.JsonPatch GHC.Types.Word instance Data.Aeson.Diff.Generic.Types.JsonPatch GHC.Word.Word8 instance Data.Aeson.Diff.Generic.Types.JsonPatch GHC.Word.Word16 instance Data.Aeson.Diff.Generic.Types.JsonPatch GHC.Word.Word32 instance Data.Aeson.Diff.Generic.Types.JsonPatch GHC.Word.Word64 instance Data.Aeson.Diff.Generic.Types.JsonPatch () instance Data.Aeson.Diff.Generic.Types.JsonPatch Data.Text.Internal.Text instance Data.Aeson.Diff.Generic.Types.JsonPatch Data.Text.Internal.Lazy.Text instance Data.Aeson.Diff.Generic.Types.JsonPatch Data.Version.Version instance Data.Aeson.Diff.Generic.Types.JsonPatch Foreign.C.Types.CTime instance Data.Aeson.Diff.Generic.Types.JsonPatch Data.IntSet.Internal.IntSet instance Data.Aeson.Diff.Generic.Types.JsonPatch Data.Scientific.Scientific instance Data.Aeson.Diff.Generic.Types.JsonPatch Data.Time.LocalTime.Internal.LocalTime.LocalTime instance Data.Aeson.Diff.Generic.Types.JsonPatch Data.Time.LocalTime.Internal.TimeOfDay.TimeOfDay instance Data.Aeson.Diff.Generic.Types.JsonPatch Data.Time.Clock.Internal.UTCTime.UTCTime instance Data.Aeson.Diff.Generic.Types.JsonPatch Data.Time.Clock.Internal.NominalDiffTime.NominalDiffTime instance Data.Aeson.Diff.Generic.Types.JsonPatch Data.Time.Clock.Internal.DiffTime.DiffTime instance Data.Aeson.Diff.Generic.Types.JsonPatch Data.Time.Calendar.Days.Day instance Data.Aeson.Diff.Generic.Types.JsonPatch Data.UUID.Types.Internal.UUID instance Data.Aeson.Diff.Generic.Types.JsonPatch Data.Aeson.Types.Internal.DotNetTime instance (Data.Hashable.Class.Hashable a, GHC.Classes.Eq a, Data.Aeson.Types.FromJSON.FromJSON a, Data.Typeable.Internal.Typeable a, Data.Aeson.Types.ToJSON.ToJSON a) => Data.Aeson.Diff.Generic.Types.JsonPatch (Data.HashSet.HashSet a) instance (Data.Typeable.Internal.Typeable a, GHC.Real.Integral a, Data.Aeson.Types.ToJSON.ToJSON a, Data.Aeson.Types.FromJSON.FromJSON a, GHC.Classes.Eq a) => Data.Aeson.Diff.Generic.Types.JsonPatch (GHC.Real.Ratio a) instance (Data.Fixed.HasResolution a, Data.Typeable.Internal.Typeable a, Data.Aeson.Types.FromJSON.FromJSON a, Data.Aeson.Types.ToJSON.ToJSON a) => Data.Aeson.Diff.Generic.Types.JsonPatch (Data.Fixed.Fixed a) instance Data.Aeson.Diff.Generic.Types.JsonPatch a => Data.Aeson.Diff.Generic.Types.JsonPatch (Data.IntMap.Internal.IntMap a) -- | This library allows you to apply a json-patch document -- (rfc6902) directly to a haskell datatype. A JSON Patch document -- is a sequence of instructions to modify a JSON value. This library -- allows you to modify the haskell datatype directly by matching it with -- its JSON representation. It is suitable for use with the HTTP PATCH -- method. module Data.Aeson.Diff.Generic -- | Apply a json patch document to the data. patch :: JsonPatch a => Patch -> a -> Result a -- | Apply a single operation to the data. applyOperation :: JsonPatch a => Operation -> a -> Result a -- | This class defines all operations necessary for applying patches. -- Instances can be written by hand, however it's easier to use the -- fieldLens class instead, or to derive it automatically using -- the template haskell functions from the -- Data.Aeson.Diff.Generic.TH module. The default implementation -- is based on fieldLens, which matches a string to a -- existentially quantified getter and setter (the GetSet -- datatype). The Instances can be found in the -- Data.Aeson.Diff.Generic.Instances module, which this module -- exports. class (Eq s, ToJSON s, FromJSON s, Typeable s) => JsonPatch s -- | Retrieve the value at the pointer. To get back a json Value use -- toJSON as the helper function, to get back a Dynamic use -- toDyn. getAtPointer :: JsonPatch s => Pointer -> s -> (forall v. JsonPatch v => v -> r) -> Result r -- | Retrieve the value at the pointer. To get back a json Value use -- toJSON as the helper function, to get back a Dynamic use -- toDyn. getAtPointer :: (JsonPatch s, FieldLens s) => Pointer -> s -> (forall v. JsonPatch v => v -> r) -> Result r -- | Remove the value at pointer from the data. The original value is -- returned. To get back a json Value use toJSON as the -- helper function, to get back a Dynamic use toDyn. deleteAtPointer :: JsonPatch s => Pointer -> s -> (forall v. JsonPatch v => v -> r) -> Result (r, s) -- | Remove the value at pointer from the data. The original value is -- returned. To get back a json Value use toJSON as the -- helper function, to get back a Dynamic use toDyn. deleteAtPointer :: (JsonPatch s, FieldLens s) => Pointer -> s -> (forall v. JsonPatch v => v -> r) -> Result (r, s) -- | Add a value at the pointer. To insert a json Value, use -- fromJSON as the helper function, to insert a Dynamic use -- getDynamic. addAtPointer :: JsonPatch s => Pointer -> s -> r -> (forall v. JsonPatch v => r -> Result v) -> Result s -- | Add a value at the pointer. To insert a json Value, use -- fromJSON as the helper function, to insert a Dynamic use -- getDynamic. addAtPointer :: (JsonPatch s, FieldLens s) => Pointer -> s -> r -> (forall v. JsonPatch v => r -> Result v) -> Result s -- | copyPath src dst s. Copy the value at src to dest in -- s. If the types don't match an error is returned copyPath :: JsonPatch s => Pointer -> Pointer -> s -> Result s -- | copyPath src dst s. Copy the value at src to dest in -- s. If the types don't match an error is returned copyPath :: (JsonPatch s, FieldLens s) => Pointer -> Pointer -> s -> Result s -- | movePath src dst s. Move the value from src to dest -- in s. If the types don't match an error is returned movePath :: JsonPatch s => Pointer -> Pointer -> s -> Result s -- | movePath src dst s. Move the value from src to dest -- in s. If the types don't match an error is returned movePath :: (JsonPatch s, FieldLens s) => Pointer -> Pointer -> s -> Result s -- | Replace the value at the pointer with the new value. To replace using -- a json Value, use fromJSON as the helper function, to -- insert a Dynamic use getDynamic. replaceAtPointer :: JsonPatch s => Pointer -> s -> r -> (forall v. JsonPatch v => r -> Result v) -> Result s -- | Replace the value at the pointer with the new value. To replace using -- a json Value, use fromJSON as the helper function, to -- insert a Dynamic use getDynamic. replaceAtPointer :: (JsonPatch s, FieldLens s) => Pointer -> s -> r -> (forall v. JsonPatch v => r -> Result v) -> Result s -- | Test if the value at the pointer matches the given value (after -- conversion). Return the data if they match, give an error otherwise. testAtPointer :: JsonPatch s => Pointer -> s -> r -> (forall v. JsonPatch v => r -> Result v) -> Result s -- | Test if the value at the pointer matches the given value (after -- conversion). Return the data if they match, give an error otherwise. testAtPointer :: (JsonPatch s, FieldLens s) => Pointer -> s -> r -> (forall v. JsonPatch v => r -> Result v) -> Result s -- | Read a Dynamic value into the Result Monad. Gives a type -- error if the results don't match. getDynamic :: (Typeable a) => Dynamic -> Result a -- | Get the json value at the pointer. Gives an error if the destination -- doesn't exist. getValueAtPointer :: JsonPatch s => Pointer -> s -> Result Value -- | Get the value at the pointer. Gives and error If the types don't match -- or if the destination doesn't exist. getDataAtPointer :: (JsonPatch s, Typeable a) => Pointer -> s -> Result a -- | An existentially quantified getter and setter. The data inside is -- manipulated using json conversion functions (toJSON, -- fromJSON), or Data.Dynamic (getDynamic, -- toDyn, etc...). data GetSet s GetSet :: v -> (v -> Result s) -> GetSet s class (Eq s, ToJSON s, FromJSON s, Typeable s) => FieldLens s -- | Map a key to a getter and setter on the given data. fieldLens :: FieldLens s => Key -> s -> Result (GetSet s) -- | Delete and return the data at the given key. The helper function -- determines which value to return: toJSON to return an aeson -- Value, toDyn to return a Dynamic. deleteAt :: FieldLens s => Key -> s -> (forall v. (JsonPatch v) => v -> r) -> Result (r, s) -- | Insert a value at the given key. The helper function determines how to -- convert the value: fromJSON to convert from an aeson -- Value, getDynamic to convert from a Dynamic. insertAt :: FieldLens s => Key -> s -> r -> (forall v. (JsonPatch v) => r -> Result v) -> Result s