differ v0.1.0 Differ.Patchable protocol View Source
Allows to apply diff to a term
Link to this section Summary
Link to this section Types
Link to this section Functions
Performs operation op on term
First argument is original term. Second is operation, that get matched against functions in implementations. Third is a tuple, where first item should be result of the operation, and second is anything else.
Function should return tuple with :ok atom and tuple {result, anything}
Returns the opposite of operation
If operation is not revertable, should return {:error, reason}
Examples
iex> Differ.diffable.revert("", {:del, "ttypo"})
{:ok, {:ins, "ttypo"}}
iex> Differ.diffable.revert("", {:remove, 10})
{:error, "Operation is not revertable"}