Wrapper for location metadata. The location is essentially a pair of
(row,col)
coordinates for some span of source code.
Useful for error messages, but hopefully for stuff like source maps etc. too.
Holds location metadata and some value.
{ start : Position
, end : Position
}
{ row : Basics.Int, col : Basics.Int }
located : Region -> expr -> Located expr
A constructor for the Located type.
unwrap : Located a -> a
Return the value inside the wrapper.
getRegion : Located a -> Region
Return the location info inside the wrapper.
map : (a -> b) -> Located a -> Located b
Apply a function to the value inside the wrapper.
merge : (Located a -> Located a -> b) -> Located a -> Located a -> Located b
Merge the regions of the two wrappers.
replaceWith : b -> Located a -> Located b
Replace the value inside the wrapper with another.
dummyRegion : Region
Empty, meaningless region. Used in tests or where you don't need the location info but need to appease the typesystem.
mergeRegions : Region -> Region -> Region
Merge the regions: the resulting region is always bigger or equal than the input regions.
mergeRegions <1:1 - 4:4> <2:2 - 3:3>
--> <1:1 - 4:4>
The order doesn't matter:
mergeRegions <2:2 - 3:3> <1:1 - 4:4>
--> <1:1 - 4:4>
One doesn't have to be a subset of the other:
mergeRegions <1:1 - 3:3> <2:2 - 4:4>
--> <1:1 - 4:4>
There can be gaps in between
mergeRegions <1:1 - 2:2> <4:4 - 5:5>
--> <1:1 - 5:5>
regionToComparable : Region -> ( ( Basics.Int, Basics.Int ), ( Basics.Int, Basics.Int ) )
Transforms the record into something comparable
.
positionToComparable : Position -> ( Basics.Int, Basics.Int )
Transforms the record into something comparable
.
comparePosition : Position -> Position -> Basics.Order
Compare using positionToComparable