Annotations-0.1.3: Constructing, analyzing and destructing annotated trees

Annotations.Bounds

Contents

Description

Types and utility functions for expression text selections.

Synopsis

Types

type Range = (Int, Int)Source

A simple textual selection: starting offset and ending offset, respectively. Offsets are 0-based.

data Bounds Source

A structural selection expressed as a textual selection. The margins indicate the whitespace directly around the selected structure.

Constructors

Bounds 

Instances

innerRange :: Bounds -> RangeSource

A Bounds' inner range does not include the whitespace around the selected structure.

outerRange :: Bounds -> RangeSource

A Bounds' outer range includes the whitespace around the selected structure.

Membership predicates

posInRange :: Int -> Range -> BoolSource

Tells whether the offset falls within the given range.

rangeInRange :: Range -> Range -> BoolSource

Tells whether the first range is enclosed by the second range.

rangeInBounds :: Range -> Bounds -> BoolSource

A range is within certain bounds if its left offset is within the bounds' left margin and its right offset is within the bounds' right margin.

rangesInBounds :: Bounds -> [Range]Source

rangesInBounds b yields all those ranges r for which rangeInBounds r b.

distRange :: Range -> Range -> IntSource

A measure for the dissimilarity between two ranges.

distRange (l1, r1) (l2, r2) = |l1 - l2| + |r1 - r2|