Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Line-column locations and its offset monoid.
Documentation
Line and column coordinates.
The generalization over types of line and column numbers frees us from any specific indexing scheme, notably whether columns are zero- or one-indexed.
Example
abc de fgh
Assuming the lines and columns are both 1-indexed, "b"
is at location
(Colline 1 2)
and "h"
is at location (Colline 3 3)
.
Colline !l !c |
Instances
(Show l, Show c) => Show (Colline l c) Source # | |
(Amor l, Origin c) => Amor (Colline l c) Source # | |
(Origin l, Origin c) => Origin (Colline l c) Source # | |
Defined in DiffLoc.Colline | |
(Eq l, Eq c) => Eq (Colline l c) Source # | |
(Ord l, Ord c) => Ord (Colline l c) Source # | |
Defined in DiffLoc.Colline | |
type Trans (Colline l c) Source # | |
The space between two Colline
s.
This type represents offsets between text locations x <= y
as the number of newlines inbetween and the number of characters
from the last new line to y
, if there is at least one newline,
or the number of characters from x
to y
.
Example
abc de fgh
- The offset from
"b"
to"h"
isVallee 2 2
(two newlines to reach line 3, and from the beginning of that line, advance two characters to reach h). - The offset from
"b"
to"c"
isVallee 0 1
(advance one character).
The offset from "b"
to "h"
is actually the same as from "a"
to "h"
and from "c"
to "h"
. Line-column offsets are thus not invertible.
This was one of the main constraints in the design of the Amor
class.
Vallee !dl !dc |
Instances
(Monoid l, Eq l, Monoid c) => Monoid (Vallee l c) Source # | |
(Monoid l, Eq l, Semigroup c) => Semigroup (Vallee l c) Source # | |
(Show dl, Show dc) => Show (Vallee dl dc) Source # | |
(Eq dl, Eq dc) => Eq (Vallee dl dc) Source # | |
(Ord dl, Ord dc) => Ord (Vallee dl dc) Source # | |
Defined in DiffLoc.Colline |