Copyright | (c) Alec Theriault 2017-2018 |
---|---|
License | BSD-style |
Maintainer | alec.theriault@gmail.com |
Stability | experimental |
Portability | GHC |
Safe Haskell | Safe |
Language | Haskell2010 |
Everything to do with describing a position or a contiguous region in a file.
- data Position
- = Position { }
- | NoPosition
- prettyPosition :: Position -> String
- maxPos :: Position -> Position -> Position
- minPos :: Position -> Position -> Position
- initPos :: Position
- incPos :: Position -> Int -> Position
- retPos :: Position -> Position
- incOffset :: Position -> Int -> Position
- data Span = Span {}
- unspan :: Spanned a -> a
- prettySpan :: Span -> String
- subsetOf :: Span -> Span -> Bool
- (#) :: (Located a, Located b) => a -> b -> Span
- data Spanned a = Spanned a !Span
- class Located a where
Positions in files
A position in a source file. The row and column information is kept only for its convenience and human-readability. Analogous to the information encoded in a cursor.
maxPos :: Position -> Position -> Position Source #
Maximum of two positions, bias for actual positions.
>>>
maxPos (Position 30 5 8) (Position 37 5 15)
Position 37 5 15
>>>
maxPos NoPosition (Position 30 5 8)
Position 30 5 8
minPos :: Position -> Position -> Position Source #
Maximum and minimum positions, bias for actual positions.
>>>
minPos (Position 30 5 8) (Position 37 5 15)
Position 30 5 8
>>>
minPos NoPosition (Position 30 5 8)
Position 30 5 8
incOffset :: Position -> Int -> Position Source #
Advance only the absolute offset, not the row and column information. Only use this if you know what you are doing!
Spans in files
Spans represent a contiguous region of code, delimited by two Position
s. The endpoints are
inclusive. Analogous to the information encoded in a selection.
Eq Span Source # | |
Data Span Source # | |
Ord Span Source # | |
Show Span Source # | Field names are not shown |
Generic Span Source # | |
Semigroup Span Source # | smallest covering |
Monoid Span Source # | |
NFData Span Source # | |
Located Span Source # | |
Pretty Span Source # | |
Parse (WhereClause Span) Source # | |
Parse (TyParam Span) Source # | |
Parse (Ty Span) Source # | |
Parse (TraitItem Span) Source # | |
Parse (Stmt Span) Source # | |
Parse (Pat Span) Source # | |
Parse (Lit Span) Source # | |
Parse (SourceFile Span) Source # | |
Parse (LifetimeDef Span) Source # | |
Parse (Item Span) Source # | |
Parse (ImplItem Span) Source # | |
Parse (Generics Span) Source # | |
Parse (Expr Span) Source # | |
Parse (Block Span) Source # | |
Parse (Attribute Span) Source # | |
type Rep Span Source # | |
A "tagging" of something with a Span
that describes its extent.
Monad Spanned Source # | |
Functor Spanned Source # | |
Applicative Spanned Source # | |
Eq a => Eq (Spanned a) Source # | |
Data a => Data (Spanned a) Source # | |
Ord a => Ord (Spanned a) Source # | |
Show a => Show (Spanned a) Source # | |
Generic (Spanned a) Source # | |
NFData a => NFData (Spanned a) Source # | |
Located (Spanned a) Source # | |
type Rep (Spanned a) Source # | |
class Located a where Source #
Describes nodes that can be located - their span can be extracted from them. In general, we
expect that for a value constructed as Con x y z
where Con
is an arbitrary constructor
(spanOf x <> spanOf y <> spanOf z) `subsetOf` spanOf (Con x y z) == True