| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
DiffLoc.Shift
Description
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<$>shiftRr s =shiftBlockr (srcs)tgt<$>shiftRr s =shiftBlockr (tgts)src<$>coshiftRr s =coshiftBlockr (srcs)tgt<$>coshiftRr s =coshiftBlockr (tgts)shiftBlockr b = Just d <==>coshiftBlockr d = Just bshiftRr s = Just z <==>coshiftRr z = Just sshiftRr s = Just z &&shiftRs r = Just q ==> z<>r = q<>scoshiftRr s = Just z &&coshiftRs r = Just q ==> r<>z = s<>q
Duality laws:
src = tgt .dualtgt = src .dualshiftBlock = coshiftBlock .dualcoshiftBlock = shiftBlock .dualcoshiftR = shiftR .dualshiftR = coshiftR .dual
Minimal complete definition
Methods
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 Methods 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 (.Transp))
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,jfinds a vector.-.?insuch 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
Methods
(.+) :: 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(fromOriginx) = xfromOrigin(ofOriginv) = vfromOrigin(x .+ v) =fromOriginx <> v