Copyright | Copyright 2017 Awake Security |
---|---|
License | Apache-2.0 |
Maintainer | opensource@awakesecurity.com |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
Language.Ninja.Misc.Located0.1.0
Description
Tokenize text into a list of non-whitespace chunks, each of which is annotated with its source location.
- data Located t
- tokenize :: Maybe Path -> Text -> [Located Text]
- tokenizeFile :: MonadReadFile m => Path -> m [Located Text]
- tokenizeText :: Text -> [Located Text]
- locatedPos :: Lens' (Located t) Position
- locatedVal :: Lens' (Located t) t
- data Spans
- makeSpans :: [Span] -> Spans
- spansSet :: Iso' Spans (HashSet Span)
- data Span
- makeSpan :: Maybe Path -> Offset -> Offset -> Span
- spanPath :: Lens' Span (Maybe Path)
- spanRange :: Lens' Span (Offset, Offset)
- spanStart :: Lens' Span Offset
- spanEnd :: Lens' Span Offset
- spanStartPos :: Getter Span Position
- spanEndPos :: Getter Span Position
- data Position
- makePosition :: Maybe Path -> Offset -> Position
- positionFile :: Lens' Position (Maybe Path)
- positionOffset :: Lens' Position Offset
- positionLine :: Lens' Position Line
- positionCol :: Lens' Position Column
- comparePosition :: Position -> Position -> Maybe Ordering
- type Offset = (Line, Column)
- compareOffset :: Offset -> Offset -> Ordering
- offsetLine :: Lens' Offset Line
- offsetColumn :: Lens' Offset Column
- type Line = Int
- type Column = Int
Located
This datatype represents a value annotated with a source location.
Instances
Functor Located | #Source | |
Foldable Located | #Source | |
Traversable Located | #Source | |
(Monad m, Serial m Text, Serial m t) => Serial m (Located t) | #Source | |
(Monad m, CoSerial m Text, CoSerial m t) => CoSerial m (Located t) | #Source | |
Eq t => Eq (Located t) | #Source | |
Show t => Show (Located t) | #Source | |
Generic (Located t) | #Source | |
Hashable t => Hashable (Located t) | #Source | |
ToJSON t => ToJSON (Located t) | #Source | Converts to |
FromJSON t => FromJSON (Located t) | #Source | Inverse of the |
NFData t => NFData (Located t) | #Source | |
type Rep (Located t) | #Source | |
tokenizeFile :: MonadReadFile m => Path -> m [Located Text] Source 0.1.0#
tokenizeText :: Text -> [Located Text] Source 0.1.0#
This function is equivalent to tokenize Nothing
.
locatedVal :: Lens' (Located t) t Source 0.1.0#
The value underlying this located value.
Spans
A type representing a set of source spans.
Instances
Eq Spans | #Source | |
Show Spans | #Source | |
Generic Spans | #Source | |
Semigroup Spans | #Source | |
Monoid Spans | #Source | |
Hashable Spans | #Source | |
ToJSON Spans | #Source | |
FromJSON Spans | #Source | |
NFData Spans | #Source | |
(Monad m, Serial m (HashSet Span)) => Serial m Spans | #Source | |
(Monad m, CoSerial m (HashSet Span)) => CoSerial m Spans | #Source | |
type Rep Spans | #Source | |
Span
Represents a span of source code.
Instances
Eq Span | #Source | |
Show Span | #Source | |
Generic Span | #Source | |
Hashable Span | #Source | |
ToJSON Span | #Source | Converts to |
FromJSON Span | #Source | Inverse of the |
NFData Span | #Source | |
(Monad m, Serial m Text) => Serial m Span | #Source | |
(Monad m, CoSerial m Text) => CoSerial m Span | #Source | |
type Rep Span | #Source | |
Arguments
:: Maybe Path | The file in which this span resides, if any. |
-> Offset | The start offset. |
-> Offset | The end offset. |
-> Span |
Construct a Span
from a given start position to a given end position.
spanPath :: Lens' Span (Maybe Path) Source 0.1.0#
A lens into the (nullable) path associated with a Span
.
Position
This datatype represents the position of a cursor in a text file.
Instances
Eq Position | #Source | |
Show Position | #Source | |
Generic Position | #Source | |
Hashable Position | #Source | |
ToJSON Position | #Source | Converts to |
FromJSON Position | #Source | Inverse of the |
NFData Position | #Source | |
(Monad m, Serial m Text) => Serial m Position | #Source | |
(Monad m, CoSerial m Text) => CoSerial m Position | #Source | |
type Rep Position | #Source | |
makePosition :: Maybe Path -> Offset -> Position Source 0.1.0#
Construct a Position
from a (nullable) path and a (line, column)
pair.
positionFile :: Lens' Position (Maybe Path) Source 0.1.0#
The path of the file pointed to by this position, if any.
positionOffset :: Lens' Position Offset Source 0.1.0#
The offset in the file pointed to by this position.
positionLine :: Lens' Position Line Source 0.1.0#
The line number in the file pointed to by this position.
positionCol :: Lens' Position Column Source 0.1.0#
The column number in the line pointed to by this position.
Offset
offsetColumn :: Lens' Offset Column Source 0.1.0#
A lens into the Line
associated with an Offset
.
Read the description of offsetLine
for an understanding of why this
exists and why you should use it instead of _2
.