Annotations-0.2.1: Constructing, analyzing and destructing annotated trees

Safe HaskellSafe-Inferred
LanguageHaskell98

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 -> Range Source

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

outerRange :: Bounds -> Range Source

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

Membership predicates

posInRange :: Int -> Range -> Bool Source

Tells whether the offset falls within the given range.

rangeInRange :: Range -> Range -> Bool Source

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

rangeInBounds :: Range -> Bounds -> Bool Source

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 -> Int Source

A measure for the dissimilarity between two ranges.

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