Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Unison.LSP.Util.IntersectionMap
Synopsis
- intersectionsFromList :: Ord pos => [((pos, pos), a)] -> IntersectionMap pos a
- intersectionsSingleton :: (pos, pos) -> a -> IntersectionMap pos a
- class Ord pos => IntersectionRange pos where
- intersects :: pos -> (pos, pos) -> Bool
- isTighterThan :: (pos, pos) -> (pos, pos) -> Bool
- data IntersectionMap pos a
- smallestIntersection :: IntersectionRange pos => pos -> IntersectionMap pos a -> Maybe ((pos, pos), a)
- data KeyedIntersectionMap k pos a
- keyedFromList :: (Ord k, IntersectionRange pos) => [(k, ((pos, pos), a))] -> KeyedIntersectionMap k pos a
- keyedSingleton :: (Ord k, IntersectionRange pos) => k -> (pos, pos) -> a -> KeyedIntersectionMap k pos a
- keyedSmallestIntersection :: (Ord k, IntersectionRange pos) => k -> pos -> KeyedIntersectionMap k pos a -> Maybe ((pos, pos), a)
Intersection map
intersectionsFromList :: Ord pos => [((pos, pos), a)] -> IntersectionMap pos a Source #
Construct an intersection map from a list of ranges and values. Duplicates are dropped.
intersectionsSingleton :: (pos, pos) -> a -> IntersectionMap pos a Source #
class Ord pos => IntersectionRange pos where Source #
Class for types that can be used as ranges for intersection maps.
Methods
intersects :: pos -> (pos, pos) -> Bool Source #
isTighterThan :: (pos, pos) -> (pos, pos) -> Bool Source #
Instances
IntersectionRange Position Source # | |
Defined in Unison.LSP.Util.IntersectionMap Methods intersects :: Position -> (Position, Position) -> Bool Source # isTighterThan :: (Position, Position) -> (Position, Position) -> Bool Source # |
data IntersectionMap pos a Source #
Instances
smallestIntersection :: IntersectionRange pos => pos -> IntersectionMap pos a -> Maybe ((pos, pos), a) Source #
NOTE: Assumes that ranges only NEST and never overlap, which is an invariant that should be maintained by the ABT annotations.
Returns the value associated with the tightest span which intersects with the given position.
>>>
smallestIntersection (LSP.Position 5 1) (intersectionsFromList [((LSP.Position 1 1, LSP.Position 3 1), "a"), ((LSP.Position 2 1, LSP.Position 8 1), "b"), ((LSP.Position 4 1, LSP.Position 6 1), "c")])
Just ((Position {_line = 4, _character = 1},Position {_line = 6, _character = 1}),"c")>>>
smallestIntersection (LSP.Position 5 3) (intersectionsFromList [((LSP.Position 1 1, LSP.Position 3 1), "a"), ((LSP.Position 4 2, LSP.Position 6 5), "b"), ((LSP.Position 4 1, LSP.Position 6 6), "c"), ((LSP.Position 7 1, LSP.Position 9 1), "d")])
Just ((Position {_line = 4, _character = 2},Position {_line = 6, _character = 5}),"b")
Keyed intersection map
data KeyedIntersectionMap k pos a Source #
An intersection map where intersections are partitioned by a key.
Instances
keyedFromList :: (Ord k, IntersectionRange pos) => [(k, ((pos, pos), a))] -> KeyedIntersectionMap k pos a Source #
keyedSingleton :: (Ord k, IntersectionRange pos) => k -> (pos, pos) -> a -> KeyedIntersectionMap k pos a Source #
keyedSmallestIntersection :: (Ord k, IntersectionRange pos) => k -> pos -> KeyedIntersectionMap k pos a -> Maybe ((pos, pos), a) Source #
NOTE: Assumes that ranges only NEST and never overlap, which is an invariant that should be maintained by the ABT annotations.
Returns the value associated with the tightest span which intersects with the given position.