package patience_diff

  1. Overview
  2. Docs

Module Patience_diff.RangeSource

For handling diffs abstractly. A range is a subarray of the two original arrays with a constructor defining its relationship to the two original arrays. A Same range contains a series of elements which can be found in both arrays. A Next range contains elements found only in the second array, while an Prev range contains elements found only in the first array.

If a range is part of a move it will have a non-None Move_kind.t or Move_id.t in the case of Replace and Unified. A Prev with a Move _ Move_kind means that Prev has a corresponding Next that it was moved to. A Prev with a Within_move _ Move_kind means that this was some code that was deleted within a block that moved to a Next position of the file. If a Replace or Unified range is associated with a move it can only be change within a move so they only hove a Move_id.t option instead of a Move_kind.t option like Prev or Next.

A Replace contains two arrays: elements in the first output array are elements found only in the first input array, which have been replaced by elements in the second output array, which are elements found only in the second input array.

Sourcetype 'a t =
  1. | Same of ('a * 'a) array
  2. | Prev of 'a array * Patience_diff_lib__.Move_kind.t option
  3. | Next of 'a array * Patience_diff_lib__.Move_kind.t option
  4. | Replace of 'a array * 'a array * Patience_diff_lib__.Move_id.t option
  5. | Unified of 'a array * Patience_diff_lib__.Move_id.t option
include Sexplib0.Sexpable.S1 with type 'a t := 'a t
Sourceval t_of_sexp : (Sexplib0.Sexp.t -> 'a) -> Sexplib0.Sexp.t -> 'a t
Sourceval sexp_of_t : ('a -> Sexplib0.Sexp.t) -> 'a t -> Sexplib0.Sexp.t
Sourceval all_same : 'a t list -> bool

all_same ranges returns true if all ranges are Same

Sourceval prev_only : 'a t list -> 'a t list

prev_only ranges drops all Next ranges and converts all Replace ranges to Prev ranges.

Sourceval next_only : 'a t list -> 'a t list

next_only ranges drops all Prev ranges and converts all Replace ranges to Next ranges.

Sourceval prev_size : 'a t -> int

Counts number of elements.

Sourceval next_size : 'a t -> int
Sourcemodule Stable : sig ... end