-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Extract and apply patches to JSON documents.
--   
--   This is a small library for working with changes to JSON documents. It
--   includes a library and two command-line executables in the style of
--   the diff(1) and patch(1) commands available on many systems.
@package aeson-diff
@version 1.1.0.13


module Data.Aeson.Pointer

-- | Pointer to a location in a JSON document.
--   
--   Defined in RFC 6901 <a>http://tools.ietf.org/html/rfc6901</a>
newtype Pointer
Pointer :: Path -> Pointer
[pointerPath] :: Pointer -> Path

-- | Path components to traverse a single layer of a JSON document.
data Key

-- | Traverse a <a>Value</a> with an <a>Object</a> constructor.
OKey :: Key -> Key

-- | Traverse a <a>Value</a> with an <a>Array</a> constructor.
AKey :: Int -> Key

-- | A sequence of <a>Key</a>s forms a path through a JSON document.
type Path = [Key]

-- | Format a <a>Pointer</a> as described in RFC 6901.
--   
--   <pre>
--   &gt;&gt;&gt; formatPointer (Pointer [])
--   ""
--   
--   &gt;&gt;&gt; formatPointer (Pointer [OKey ""])
--   "/"
--   
--   &gt;&gt;&gt; formatPointer (Pointer [OKey " "])
--   "/ "
--   
--   &gt;&gt;&gt; formatPointer (Pointer [OKey "foo"])
--   "/foo"
--   
--   &gt;&gt;&gt; formatPointer (Pointer [OKey "foo", AKey 0])
--   "/foo/0"
--   
--   &gt;&gt;&gt; formatPointer (Pointer [OKey "a/b"])
--   "/a~1b"
--   
--   &gt;&gt;&gt; formatPointer (Pointer [OKey "c%d"])
--   "/c%d"
--   
--   &gt;&gt;&gt; formatPointer (Pointer [OKey "e^f"])
--   "/e^f"
--   
--   &gt;&gt;&gt; formatPointer (Pointer [OKey "g|h"])
--   "/g|h"
--   
--   &gt;&gt;&gt; formatPointer (Pointer [OKey "i\\j"])
--   "/i\\j"
--   
--   &gt;&gt;&gt; formatPointer (Pointer [OKey "k\"l"])
--   "/k\"l"
--   
--   &gt;&gt;&gt; formatPointer (Pointer [OKey "m~n"])
--   "/m~0n"
--   </pre>
formatPointer :: Pointer -> Text

-- | Parse a <a>Pointer</a> as described in RFC 6901.
parsePointer :: Text -> Parser Pointer

-- | Follow a <a>Pointer</a> through a JSON document as described in RFC
--   6901.
get :: Pointer -> Value -> Result Value

-- | Report an error while following a pointer.
pointerFailure :: Pointer -> Value -> Result a
instance GHC.Classes.Eq Data.Aeson.Pointer.Key
instance GHC.Classes.Eq Data.Aeson.Pointer.Pointer
instance Data.Aeson.Types.FromJSON.FromJSON Data.Aeson.Pointer.Key
instance Data.Aeson.Types.FromJSON.FromJSON Data.Aeson.Pointer.Pointer
instance GHC.Internal.Generics.Generic Data.Aeson.Pointer.Key
instance GHC.Internal.Generics.Generic Data.Aeson.Pointer.Pointer
instance GHC.Internal.Base.Monoid Data.Aeson.Pointer.Pointer
instance GHC.Classes.Ord Data.Aeson.Pointer.Key
instance GHC.Classes.Ord Data.Aeson.Pointer.Pointer
instance GHC.Internal.Base.Semigroup Data.Aeson.Pointer.Pointer
instance GHC.Internal.Show.Show Data.Aeson.Pointer.Key
instance GHC.Internal.Show.Show Data.Aeson.Pointer.Pointer
instance Data.Aeson.Types.ToJSON.ToJSON Data.Aeson.Pointer.Key
instance Data.Aeson.Types.ToJSON.ToJSON Data.Aeson.Pointer.Pointer


module Data.Aeson.Patch

-- | Describes the changes between two JSON documents.
newtype Patch
Patch :: [Operation] -> Patch
[patchOperations] :: Patch -> [Operation]

-- | An <a>Operation</a> describes the operations which can appear as part
--   of a JSON Patch.
--   
--   See RFC 6902 Section 4
--   <a>http://tools.ietf.org/html/rfc6902#section-4</a>.
data Operation

-- | <a>http://tools.ietf.org/html/rfc6902#section-4.1</a>
Add :: Pointer -> Value -> Operation
[changePointer] :: Operation -> Pointer
[changeValue] :: Operation -> Value

-- | <a>http://tools.ietf.org/html/rfc6902#section-4.5</a>
Cpy :: Pointer -> Pointer -> Operation
[changePointer] :: Operation -> Pointer
[fromPointer] :: Operation -> Pointer

-- | <a>http://tools.ietf.org/html/rfc6902#section-4.4</a>
Mov :: Pointer -> Pointer -> Operation
[changePointer] :: Operation -> Pointer
[fromPointer] :: Operation -> Pointer

-- | <a>http://tools.ietf.org/html/rfc6902#section-4.2</a>
Rem :: Pointer -> Operation
[changePointer] :: Operation -> Pointer

-- | <a>http://tools.ietf.org/html/rfc6902#section-4.3</a>
Rep :: Pointer -> Value -> Operation
[changePointer] :: Operation -> Pointer
[changeValue] :: Operation -> Value

-- | <a>http://tools.ietf.org/html/rfc6902#section-4.6</a>
Tst :: Pointer -> Value -> Operation
[changePointer] :: Operation -> Pointer
[changeValue] :: Operation -> Value

-- | Modify the <a>Pointer</a>s in an <a>Operation</a>.
--   
--   If the operation contains multiple pointers (i.e. a <a>Mov</a> or
--   <a>Cpy</a>) then both will be modified.
modifyPointer :: (Pointer -> Pointer) -> Operation -> Operation

-- | Modify the pointers in the <a>Operation</a>s of a <a>Patch</a>.
--   
--   See <a>modifyPointer</a> for details.
modifyPointers :: (Pointer -> Pointer) -> Patch -> Patch
isAdd :: Operation -> Bool
isRem :: Operation -> Bool
isRep :: Operation -> Bool
isMov :: Operation -> Bool
isCpy :: Operation -> Bool
isTst :: Operation -> Bool
instance GHC.Classes.Eq Data.Aeson.Patch.Operation
instance GHC.Classes.Eq Data.Aeson.Patch.Patch
instance Data.Aeson.Types.FromJSON.FromJSON Data.Aeson.Patch.Operation
instance Data.Aeson.Types.FromJSON.FromJSON Data.Aeson.Patch.Patch
instance GHC.Internal.Generics.Generic Data.Aeson.Patch.Operation
instance GHC.Internal.Generics.Generic Data.Aeson.Patch.Patch
instance GHC.Internal.Base.Monoid Data.Aeson.Patch.Patch
instance GHC.Internal.Base.Semigroup Data.Aeson.Patch.Patch
instance GHC.Internal.Show.Show Data.Aeson.Patch.Operation
instance GHC.Internal.Show.Show Data.Aeson.Patch.Patch
instance Data.Aeson.Types.ToJSON.ToJSON Data.Aeson.Patch.Operation
instance Data.Aeson.Types.ToJSON.ToJSON Data.Aeson.Patch.Patch


-- | This module implements data types and operations to represent the
--   differences between JSON documents (i.e. a patch), to compare JSON
--   documents and extract such a patch, and to apply such a patch to a
--   JSON document.
module Data.Aeson.Diff

-- | Describes the changes between two JSON documents.
newtype Patch
Patch :: [Operation] -> Patch

-- | Pointer to a location in a JSON document.
--   
--   Defined in RFC 6901 <a>http://tools.ietf.org/html/rfc6901</a>
data Pointer

-- | Path components to traverse a single layer of a JSON document.
data Key

-- | Traverse a <a>Value</a> with an <a>Object</a> constructor.
OKey :: Key -> Key

-- | Traverse a <a>Value</a> with an <a>Array</a> constructor.
AKey :: Int -> Key

-- | An <a>Operation</a> describes the operations which can appear as part
--   of a JSON Patch.
--   
--   See RFC 6902 Section 4
--   <a>http://tools.ietf.org/html/rfc6902#section-4</a>.
data Operation

-- | <a>http://tools.ietf.org/html/rfc6902#section-4.1</a>
Add :: Pointer -> Value -> Operation
[changePointer] :: Operation -> Pointer
[changeValue] :: Operation -> Value

-- | <a>http://tools.ietf.org/html/rfc6902#section-4.5</a>
Cpy :: Pointer -> Pointer -> Operation

-- | <a>http://tools.ietf.org/html/rfc6902#section-4.4</a>
Mov :: Pointer -> Pointer -> Operation

-- | <a>http://tools.ietf.org/html/rfc6902#section-4.2</a>
Rem :: Pointer -> Operation
[changePointer] :: Operation -> Pointer

-- | <a>http://tools.ietf.org/html/rfc6902#section-4.3</a>
Rep :: Pointer -> Value -> Operation
[changePointer] :: Operation -> Pointer
[changeValue] :: Operation -> Value

-- | <a>http://tools.ietf.org/html/rfc6902#section-4.6</a>
Tst :: Pointer -> Value -> Operation
[changePointer] :: Operation -> Pointer
[changeValue] :: Operation -> Value

-- | Configuration for the diff algorithm.
newtype Config
Config :: Bool -> Config
[configTstBeforeRem] :: Config -> Bool

-- | Compare two JSON documents and generate a patch describing the
--   differences.
--   
--   Uses the <a>defaultConfig</a>.
diff :: Value -> Value -> Patch

-- | Compare two JSON documents and generate a patch describing the
--   differences.
diff' :: Config -> Value -> Value -> Patch

-- | Apply a patch to a JSON document.
patch :: Patch -> Value -> Result Value

-- | Apply an <a>Operation</a> to a <a>Value</a>.
applyOperation :: Operation -> Value -> Result Value
