Skip to content

ADD and REMOVE in a vector instead of MOVE #52

Description

@symbiont-sam-halliday

Hi, thanks for writing this library! It's great for printing out much simplified test assertion data when asserting equality on objects with a JSON form (in leiu of a dedicated delta / diff framework).

I have noticed that when an element is moved in a list, I'm seeing an ADD/REMOVE instead of a MOVE. I assume this comes from the edit-distance library under the hood which presumably doesn't detect MOVE operations. If there is a cleanup stage it might be worth adding a rewrite rule to simplify forms of this shape.

Minimal repro

#! /usr/bin/env cabal
{- cabal:
build-depends: base, aeson, aeson-diff
-}
module Main where

import Data.Aeson
import Data.Aeson.Diff

main :: IO ()
main = do
  let lst1 = toJSON ["a", "b", "c"]
      lst2 = toJSON ["a", "c", "b"]
  putStrLn . show $ diff lst1 lst2

got

Patch {patchOperations = [
  Add {changePointer = Pointer {pointerPath = [AKey 1]}, changeValue = String "c"},
  Rem {changePointer = Pointer {pointerPath = [AKey 3]}}]}

expected a Mov.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions