Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Interfaces of structures used to implement ADiff
.
Synopsis
- class (Semigroup r, BlockOrder (Block r)) => Shift r where
- class BlockOrder b where
- precedes :: b -> b -> Bool
- distantlyPrecedes :: b -> b -> Bool
- class (Ord p, Ord (Trans p), Monoid (Trans p)) => Amor p where
- class Amor p => Origin p where
- origin :: p
- fromOrigin :: Origin p => p -> Trans p
- ofOrigin :: Origin p => Trans p -> p
Interfaces
Replacement
class (Semigroup r, BlockOrder (Block r)) => Shift r where Source #
Shift algebra.
Laws:
src
<$>shiftR
r s =shiftBlock
r (src
s)tgt
<$>shiftR
r s =shiftBlock
r (tgt
s)src
<$>coshiftR
r s =coshiftBlock
r (src
s)tgt
<$>coshiftR
r s =coshiftBlock
r (tgt
s)shiftBlock
r b = Just d <==>coshiftBlock
r d = Just bshiftR
r s = Just z <==>coshiftR
r z = Just sshiftR
r s = Just z &&shiftR
s r = Just q ==> z<>
r = q<>
scoshiftR
r s = Just z &&coshiftR
s r = Just q ==> r<>
z = s<>
q
Duality laws:
src = tgt .dual
tgt = src .dual
shiftBlock = coshiftBlock .dual
coshiftBlock = shiftBlock .dual
coshiftR = shiftR .dual
shiftR = coshiftR .dual
shiftBlock :: r -> Block r -> Maybe (Block r) Source #
coshiftBlock :: r -> Block r -> Maybe (Block r) Source #
shiftR :: r -> r -> Maybe r Source #
Instances
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 # |
class BlockOrder b where Source #
Partial ordering of interval-like things.
Indices and offsets
class (Ord p, Ord (Trans p), Monoid (Trans p)) => Amor p where Source #
Action d'un Monoïde Ordonné. Ordered monoid actions.
- An ordered set of points
Ord p
. - An ordered monoid of translations (or "vectors")
(Ord (Trans p), Monoid (
.Trans
p))
In addition to the Ord
and Monoid
laws, ordered monoids must
have a monotone (
:<>
)
v <= v' ==> w <= w' => (v<>
w) <= (v'<>
w')
- Points can be translated along vectors using
(
..+
) - Given two ordered points
i <= j
,j
finds a vector.-.?
in
such thati + n = j
.
In other words, we only require the existence of "positive" translations (this is unlike affine spaces, where translations exist between any two points). This makes it possible to implement this class for line-column locations (DiffLoc.Colline), where translations are not invertible.
(
is not part of a standard definition of ordered monoid actions.
Feel free to suggest a better name for this structure or a way to not
depend on this operation..-.?
)
Laws:
(x.+
v).+
w = x.+
(v<>
w) x<=
y ==> x.+
(y.-.
x) = y (x.+
v).-.
x = x
(.+) :: p -> Trans p -> p infixr 6 Source #
Translate a point.
(.-.?) :: p -> p -> Maybe (Trans p) Source #
Translation between two points.
j .-.? i
must be defined (Just
) if i <= j
,
There is an unsafe wrapper (
in DiffLoc.Unsafe..-.
)
class Amor p => Origin p where Source #
Extend Amor
with an "origin" point from which vectors can be drawn to
all points. To make the interface slightly more general, only the partial
application (origin .-.)
needs to be supplied.
Laws:
origin
<= x
fromOrigin :: Origin p => p -> Trans p Source #
Find the vector from the origin to this point.
x <= y = fromOrigin x <= fromOrigin yofOrigin
(fromOrigin
x) = xfromOrigin
(ofOrigin
v) = vfromOrigin
(x .+ v) =fromOrigin
x <> v