Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module deals with updating spans of characters in values of type Text.
It defines some helper types and functions to apply these "updates".
Synopsis
- data SpanUpdate = SpanUpdate {}
- data SrcSpan = SrcSpan {}
- data SourcePos = SourcePos {
- sourceName :: FilePath
- sourceLine :: !Pos
- sourceColumn :: !Pos
- updateSpan :: SpanUpdate -> Text -> Text
- updateSpans :: [SpanUpdate] -> Text -> Text
- linearizeSourcePos :: Text -> Int64 -> Int64 -> Int64
- prettyPrintSourcePos :: SourcePos -> String
- split :: SourcePos -> Text -> (Text, Text)
Documentation
data SpanUpdate Source #
A span and some text to replace it with. They don't have to be the same length.
Instances
Data SpanUpdate Source # | |
Defined in Update.Span gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> SpanUpdate -> c SpanUpdate # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c SpanUpdate # toConstr :: SpanUpdate -> Constr # dataTypeOf :: SpanUpdate -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c SpanUpdate) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SpanUpdate) # gmapT :: (forall b. Data b => b -> b) -> SpanUpdate -> SpanUpdate # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SpanUpdate -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SpanUpdate -> r # gmapQ :: (forall d. Data d => d -> u) -> SpanUpdate -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> SpanUpdate -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> SpanUpdate -> m SpanUpdate # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> SpanUpdate -> m SpanUpdate # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> SpanUpdate -> m SpanUpdate # | |
Show SpanUpdate Source # | |
Defined in Update.Span showsPrec :: Int -> SpanUpdate -> ShowS # show :: SpanUpdate -> String # showList :: [SpanUpdate] -> ShowS # |
A location in a source file
Instances
The data type SourcePos
represents source positions. It contains the
name of the source file, a line number, and a column number. Source line
and column positions change intensively during parsing, so we need to
make them strict to avoid memory leaks.
SourcePos | |
|
Instances
Eq SourcePos | |
Data SourcePos | |
Defined in Text.Megaparsec.Pos gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> SourcePos -> c SourcePos # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c SourcePos # toConstr :: SourcePos -> Constr # dataTypeOf :: SourcePos -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c SourcePos) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SourcePos) # gmapT :: (forall b. Data b => b -> b) -> SourcePos -> SourcePos # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SourcePos -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SourcePos -> r # gmapQ :: (forall d. Data d => d -> u) -> SourcePos -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> SourcePos -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> SourcePos -> m SourcePos # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> SourcePos -> m SourcePos # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> SourcePos -> m SourcePos # | |
Ord SourcePos | |
Defined in Text.Megaparsec.Pos | |
Read SourcePos | |
Show SourcePos | |
Generic SourcePos | |
NFData SourcePos | |
Defined in Text.Megaparsec.Pos | |
type Rep SourcePos | |
Defined in Text.Megaparsec.Pos type Rep SourcePos = D1 (MetaData "SourcePos" "Text.Megaparsec.Pos" "megaparsec-8.0.0-BFw8gNuiOzWGglmtIkYt5X" False) (C1 (MetaCons "SourcePos" PrefixI True) (S1 (MetaSel (Just "sourceName") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 FilePath) :*: (S1 (MetaSel (Just "sourceLine") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Pos) :*: S1 (MetaSel (Just "sourceColumn") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Pos)))) |
updateSpan :: SpanUpdate -> Text -> Text Source #
Update a single span of characters inside a text value. If you're updating
multiples spans it's best to use updateSpans
.
updateSpans :: [SpanUpdate] -> Text -> Text Source #
Update many spans in a file. They must be non-overlapping.