unison-cli-0.0.0
Safe HaskellSafe-Inferred
LanguageHaskell2010

Unison.LSP.Util.IntersectionMap

Synopsis

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

Instances details
IntersectionRange Position Source # 
Instance details

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

Instances details
Ord pos => Monoid (IntersectionMap pos a) Source # 
Instance details

Defined in Unison.LSP.Util.IntersectionMap

Ord pos => Semigroup (IntersectionMap pos a) Source # 
Instance details

Defined in Unison.LSP.Util.IntersectionMap

Methods

(<>) :: IntersectionMap pos a -> IntersectionMap pos a -> IntersectionMap pos a #

sconcat :: NonEmpty (IntersectionMap pos a) -> IntersectionMap pos a #

stimes :: Integral b => b -> IntersectionMap pos a -> IntersectionMap pos a #

(Show pos, Show a) => Show (IntersectionMap pos a) Source # 
Instance details

Defined in Unison.LSP.Util.IntersectionMap

(Eq pos, Eq a) => Eq (IntersectionMap pos a) Source # 
Instance details

Defined in Unison.LSP.Util.IntersectionMap

Methods

(==) :: IntersectionMap pos a -> IntersectionMap pos a -> Bool #

(/=) :: IntersectionMap pos a -> IntersectionMap pos a -> Bool #

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

Instances details
(Ord k, Ord pos) => Monoid (KeyedIntersectionMap k pos a) Source # 
Instance details

Defined in Unison.LSP.Util.IntersectionMap

(Ord k, Ord pos) => Semigroup (KeyedIntersectionMap k pos a) Source # 
Instance details

Defined in Unison.LSP.Util.IntersectionMap

(Show k, Show pos, Show a) => Show (KeyedIntersectionMap k pos a) Source # 
Instance details

Defined in Unison.LSP.Util.IntersectionMap

(Eq k, Eq pos, Eq a) => Eq (KeyedIntersectionMap k pos a) Source # 
Instance details

Defined in Unison.LSP.Util.IntersectionMap

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.