HORIZON HASKELLDocslts/ghc-10.0.x77a86622026-10-31Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 77a8662 · 2026-10-31

ModuleAgda-2.8.0.2Haskell2010

Agda.Syntax.Position

Position information for syntax. Crucial for giving good error messages.

Contents
  1. Positions
  2. Intervals
  3. Ranges
Synopsis
  • PackageAgda-2.8.0.2
  • Exports60
  • LanguageHaskell2010
  • LicenceMIT
  • SourcePosition.hs

Positions

datadata Position' a

Represents a point in the input.

If two positions have the same srcFile and posPos components, then the final two components should be the same as well, but since this can be hard to enforce the program should not rely too much on the last two components; they are mainly there to improve error messages for the user.

Note the invariant which positions have to satisfy: positionInvariant.

Constructors

Instances16Functor, Foldable, Traversable, NFData, Eq, Ord, …
datadata RangeFile

File information used in the Position, Interval and Range types.

Constructors

  • RangeFile
    • rangeFilePath :: !AbsolutePath

      The file's path.

    • rangeFileName :: !Maybe (TopLevelModuleName' Range)

      The file's top-level module name (if applicable).

      This field is optional, but some things may break if the field is not instantiated with an actual top-level module name. For instance, the Eq and Ord instances only make use of this field.

      The field uses Maybe rather than Maybe because it should be possible to instantiate it with something that is not yet defined (see parseSource).

      This '(TopLevelModuleName' Range)' should not contain a range.

Instances35Eq, Ord, Read, Show, Generic, NFData, …
valuemovePos :: Position' a -> Char -> Position' a

Advance the position by one character. A newline character ('n') moves the position to the first character in the next line. Any other character moves the position to the next column.

Intervals

datadata Interval' a

An interval. The iEnd position is not included in the interval.

Note the invariant which intervals have to satisfy: intervalInvariant.

Instances16Functor, Foldable, Traversable, NFData, HasRange, HasRangeWithoutFile, …

Ranges

datadata Range' a

A range is a file name, plus a sequence of intervals, assumed to point to the given file. The intervals should be consecutive and separated.

Note the invariant which ranges have to satisfy: rangeInvariant.

Instances36Functor, Foldable, Traversable, ToJSON, Sized, Subst, …
newtypenewtype PrintRange a

Wrapper to indicate that range should be printed.

Constructors

Instances6Eq, Ord, Pretty, HasRange, KillRange, SetRange
classclass HasRange a where

Things that have a range are instances of this class.

Methods

Instances136HasRange, …
classclass HasRangeWithoutFile a where

Things that have a RangeWithoutFile are instances of this class.

Instances18HasRangeWithoutFile, …
classclass HasRange a => SetRange a where

If it is also possible to set the range, this is the class.

Instances should satisfy getRange (setRange r x) == r.

Methods

Instances41SetRange, …
classclass KillRange a where

Killing the range of an object sets all range information to noRange.

Methods

Instances207KillRange, …
valuefuseRanges :: Ord a => Range' a -> Range' a -> Range' a

fuseRanges r r' unions the ranges r and r'.

Meaning it finds the least range r0 that covers r and r'.

Precondition: The ranges must point to the same file (or be empty).

beginningOf r is an empty range (a single, empty interval) positioned at the beginning of r. If r does not have a beginning, then noRange is returned.

valueinterleaveRanges :: HasRangeWithoutFile a => [a] -> [a] -> ([a], [(a, a)])

Interleaves two streams of ranged elements

It will report the conflicts as a list of conflicting pairs. In case of conflict, the element with the earliest start position is placed first. In case of a tie, the element with the earliest ending position is placed first. If both tie, the element from the first list is placed first.