Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Documentation
(i
represents a span of text between index :..
n)i
and index i+n
.
The type of indices p
is expected to be an instance of Amor
.
The length n
in an interval (i :.. n)
may be zero.
The elements of the interval can be thought of as indexing the interstices between characters. A span of length zero is a single interstice between two characters, where some chunk of text may be inserted.
Example: drawing of 1 :.. 2
in "abcde".
a b c d e 0 1 2 3 4 5 ^b+c+ length = 2 ^ ^ start = 1
isZeroLength :: (Eq (Trans p), Monoid (Trans p)) => Interval p -> Bool Source #
Does the interval have length zero?
A minimalistic representation of text replacements.
A replacement
is given by a start location Replace
i n mi
, the length
n
of the interval to replace (source) and the length m
of its
replacement (target).
This representation does not keep track of the actual data being inserted.
This may overapproximate the underlying text replacement,
with intervals being wider than necessary.
For example, the transformation from "abc" to "ac" could be represented
by mkReplace 1 1 0
(replace "b" with "" at location 1), and also by
mkReplace 0 2 1
(replace "ab" with "a" at location 0).
source abc abc - b ab + a target a c a c
Insertions are replacements with source intervals of length zero. Deletions are replacements with target intervals of length zero.
Instances
Amor p => Semigroup (Replace p) Source # | The composition of two replacements The right-to-left order of composition has the nice property that when
Properties(x <> y) <> z === x <> (y <> z :: Replace (Plain Int)) |
(Show p, Show (Trans p)) => Show (Replace p) Source # | |
Amor p => Shift (Replace p) Source # | |
Defined in DiffLoc.Interval src :: Replace p -> Block (Replace p) Source # tgt :: Replace p -> Block (Replace p) Source # shiftBlock :: Replace p -> Block (Replace p) -> Maybe (Block (Replace p)) Source # coshiftBlock :: Replace p -> Block (Replace p) -> Maybe (Block (Replace p)) Source # shiftR :: Replace p -> Replace p -> Maybe (Replace p) Source # coshiftR :: Replace p -> Replace p -> Maybe (Replace p) Source # | |
(Eq p, Eq (Trans p)) => Eq (Replace p) Source # | |
type Block (Replace p) Source # | |
Defined in DiffLoc.Interval |