loc-0.1.3.8: Types representing line and column positions and ranges in text files.

Safe HaskellNone
LanguageHaskell2010

Data.Loc.Types

Description

For convenience, this module exports only the important types from Loc.

Synopsis

Documentation

data Pos Source #

Pos stands for positive integer. You can also think of it as position, because we use it to represent line and column numbers (Line and Column).

Pos has instances of several of the standard numeric typeclasses, although many of the operations throw Underflow when non-positive values result. Pos does not have an Integral instance, because there is no sensible way to implement quotRem.

Instances
Enum Pos Source #
>>> toEnum 3 :: Pos
3
>>> toEnum 0 :: Pos
*** Exception: arithmetic underflow
>>> fromEnum (3 :: Pos)
3
Instance details

Defined in Data.Loc.Pos

Methods

succ :: Pos -> Pos #

pred :: Pos -> Pos #

toEnum :: Int -> Pos #

fromEnum :: Pos -> Int #

enumFrom :: Pos -> [Pos] #

enumFromThen :: Pos -> Pos -> [Pos] #

enumFromTo :: Pos -> Pos -> [Pos] #

enumFromThenTo :: Pos -> Pos -> Pos -> [Pos] #

Eq Pos Source # 
Instance details

Defined in Data.Loc.Pos

Methods

(==) :: Pos -> Pos -> Bool #

(/=) :: Pos -> Pos -> Bool #

Num Pos Source #
>>> fromInteger 3 :: Pos
3
>>> fromInteger 0 :: Pos
*** Exception: arithmetic underflow
>>> 2 + 3 :: Pos
5
>>> 3 - 2 :: Pos
1
>>> 3 - 3 :: Pos
*** Exception: arithmetic underflow
>>> 2 * 3 :: Pos
6
>>> negate 3 :: Pos
*** Exception: arithmetic underflow
Instance details

Defined in Data.Loc.Pos

Methods

(+) :: Pos -> Pos -> Pos #

(-) :: Pos -> Pos -> Pos #

(*) :: Pos -> Pos -> Pos #

negate :: Pos -> Pos #

abs :: Pos -> Pos #

signum :: Pos -> Pos #

fromInteger :: Integer -> Pos #

Ord Pos Source # 
Instance details

Defined in Data.Loc.Pos

Methods

compare :: Pos -> Pos -> Ordering #

(<) :: Pos -> Pos -> Bool #

(<=) :: Pos -> Pos -> Bool #

(>) :: Pos -> Pos -> Bool #

(>=) :: Pos -> Pos -> Bool #

max :: Pos -> Pos -> Pos #

min :: Pos -> Pos -> Pos #

Read Pos Source # 
Instance details

Defined in Data.Loc.Pos

Real Pos Source # 
Instance details

Defined in Data.Loc.Pos

Methods

toRational :: Pos -> Rational #

Show Pos Source # 
Instance details

Defined in Data.Loc.Pos

Methods

showsPrec :: Int -> Pos -> ShowS #

show :: Pos -> String #

showList :: [Pos] -> ShowS #

ToNat Pos Source # 
Instance details

Defined in Data.Loc.Pos

Methods

toNat :: Pos -> Natural Source #

data Line Source #

Instances
Enum Line Source # 
Instance details

Defined in Data.Loc.Pos

Methods

succ :: Line -> Line #

pred :: Line -> Line #

toEnum :: Int -> Line #

fromEnum :: Line -> Int #

enumFrom :: Line -> [Line] #

enumFromThen :: Line -> Line -> [Line] #

enumFromTo :: Line -> Line -> [Line] #

enumFromThenTo :: Line -> Line -> Line -> [Line] #

Eq Line Source # 
Instance details

Defined in Data.Loc.Pos

Methods

(==) :: Line -> Line -> Bool #

(/=) :: Line -> Line -> Bool #

Num Line Source # 
Instance details

Defined in Data.Loc.Pos

Methods

(+) :: Line -> Line -> Line #

(-) :: Line -> Line -> Line #

(*) :: Line -> Line -> Line #

negate :: Line -> Line #

abs :: Line -> Line #

signum :: Line -> Line #

fromInteger :: Integer -> Line #

Ord Line Source # 
Instance details

Defined in Data.Loc.Pos

Methods

compare :: Line -> Line -> Ordering #

(<) :: Line -> Line -> Bool #

(<=) :: Line -> Line -> Bool #

(>) :: Line -> Line -> Bool #

(>=) :: Line -> Line -> Bool #

max :: Line -> Line -> Line #

min :: Line -> Line -> Line #

Read Line Source # 
Instance details

Defined in Data.Loc.Pos

Real Line Source # 
Instance details

Defined in Data.Loc.Pos

Methods

toRational :: Line -> Rational #

Show Line Source # 
Instance details

Defined in Data.Loc.Pos

Methods

showsPrec :: Int -> Line -> ShowS #

show :: Line -> String #

showList :: [Line] -> ShowS #

ToNat Line Source # 
Instance details

Defined in Data.Loc.Pos

Methods

toNat :: Line -> Natural Source #

data Column Source #

Instances
Enum Column Source # 
Instance details

Defined in Data.Loc.Pos

Eq Column Source # 
Instance details

Defined in Data.Loc.Pos

Methods

(==) :: Column -> Column -> Bool #

(/=) :: Column -> Column -> Bool #

Num Column Source # 
Instance details

Defined in Data.Loc.Pos

Ord Column Source # 
Instance details

Defined in Data.Loc.Pos

Read Column Source # 
Instance details

Defined in Data.Loc.Pos

Real Column Source # 
Instance details

Defined in Data.Loc.Pos

Show Column Source # 
Instance details

Defined in Data.Loc.Pos

ToNat Column Source # 
Instance details

Defined in Data.Loc.Pos

Methods

toNat :: Column -> Natural Source #

data Loc Source #

Stands for location. Consists of a Line and a Column. You can think of a Loc like a caret position in a text editor. Following the normal convention for text editors and such, line and column numbers start with 1.

Instances
Eq Loc Source # 
Instance details

Defined in Data.Loc.Loc

Methods

(==) :: Loc -> Loc -> Bool #

(/=) :: Loc -> Loc -> Bool #

Ord Loc Source # 
Instance details

Defined in Data.Loc.Loc

Methods

compare :: Loc -> Loc -> Ordering #

(<) :: Loc -> Loc -> Bool #

(<=) :: Loc -> Loc -> Bool #

(>) :: Loc -> Loc -> Bool #

(>=) :: Loc -> Loc -> Bool #

max :: Loc -> Loc -> Loc #

min :: Loc -> Loc -> Loc #

Read Loc Source #

readPrec = locReadPrec

Instance details

Defined in Data.Loc.Loc

Show Loc Source #

showsPrec = locShowsPrec

Instance details

Defined in Data.Loc.Loc

Methods

showsPrec :: Int -> Loc -> ShowS #

show :: Loc -> String #

showList :: [Loc] -> ShowS #

data Span Source #

A Span consists of a start location (start) and an end location (end). The end location must be greater than the start location; in other words, empty or backwards spans are not permitted.

Construct and combine spans using fromTo, fromToMay, +, and -.

Instances
Eq Span Source # 
Instance details

Defined in Data.Loc.Span

Methods

(==) :: Span -> Span -> Bool #

(/=) :: Span -> Span -> Bool #

Ord Span Source # 
Instance details

Defined in Data.Loc.Span

Methods

compare :: Span -> Span -> Ordering #

(<) :: Span -> Span -> Bool #

(<=) :: Span -> Span -> Bool #

(>) :: Span -> Span -> Bool #

(>=) :: Span -> Span -> Bool #

max :: Span -> Span -> Span #

min :: Span -> Span -> Span #

Read Span Source #

readPrec = spanReadPrec

Instance details

Defined in Data.Loc.Span

Show Span Source #

showsPrec = spanShowsPrec

Instance details

Defined in Data.Loc.Span

Methods

showsPrec :: Int -> Span -> ShowS #

show :: Span -> String #

showList :: [Span] -> ShowS #

data Area Source #

A set of non-overlapping, non-abutting Spans. You may also think of an Area like a span that can be empty or have “gaps”.

Construct and combine areas using mempty, spanArea, fromTo, +, and -.

Instances
Eq Area Source # 
Instance details

Defined in Data.Loc.Area

Methods

(==) :: Area -> Area -> Bool #

(/=) :: Area -> Area -> Bool #

Ord Area Source # 
Instance details

Defined in Data.Loc.Area

Methods

compare :: Area -> Area -> Ordering #

(<) :: Area -> Area -> Bool #

(<=) :: Area -> Area -> Bool #

(>) :: Area -> Area -> Bool #

(>=) :: Area -> Area -> Bool #

max :: Area -> Area -> Area #

min :: Area -> Area -> Area #

Read Area Source #

readPrec = areaReadPrec

Instance details

Defined in Data.Loc.Area

Show Area Source #

showsPrec = areaShowsPrec

Instance details

Defined in Data.Loc.Area

Methods

showsPrec :: Int -> Area -> ShowS #

show :: Area -> String #

showList :: [Area] -> ShowS #

Semigroup Area Source #

<> = +

Instance details

Defined in Data.Loc.Area

Methods

(<>) :: Area -> Area -> Area #

sconcat :: NonEmpty Area -> Area #

stimes :: Integral b => b -> Area -> Area #

Monoid Area Source # 
Instance details

Defined in Data.Loc.Area

Methods

mempty :: Area #

mappend :: Area -> Area -> Area #

mconcat :: [Area] -> Area #