Repository navigation
Initial release.
Provides Diffident.explain/2, returning a serializable diff (a list of tuples) comparing two Elixir values.
left = %{
user: [
%{id: 1, name: "Alice"},
%{id: 2, name: "Bob"}
],
meta: {:ok, %{count: 2}}
}
right = %{
user: [
%{id: 1, name: "Alice"},
%{id: 2, name: "Robert"},
%{id: 3, name: "Carol"}
],
meta: {:ok, %{count: 3}}
}
Diffident.explain(left, right)
# Returns:
# [
# {:changed, [:user, {Access, :at, [1]}, :name], "Bob", "Robert"},
# {:added, [:user, {Access, :at, [2]}], %{id: 3, name: "Carol"}},
# {:changed, [:meta, {Access, :elem, [1]}, :count], 2, 3}
# ]See also:
Diffident.get_in/2- Use the path returned in a diff tuple to get a valueDiffident.put_in/3- Use the path returned in a diff tuple to put a valueDiffident.to_access_compatible/1- Convert the path returned in a diff tuple to one that will work with theAccessbehavior- This is used by
Diffident.get_in/2andDiffident.put_in/3to convert the serializable MFAs toAccessfunction calls, e.g.:{Access, :elem, [1]}becomesAccess.elem(1).
- This is used by