| Copyright | (C) 2011-2019 Edward Kmett |
|---|---|
| License | BSD-style (see the file LICENSE) |
| Maintainer | Edward Kmett <ekmett@gmail.com> |
| Stability | experimental |
| Portability | non-portable |
| Safe Haskell | Safe |
| Language | Haskell2010 |
Text.Trifecta.Delta
Description
A Delta keeps track of the cursor position of the parser, so it can be
referred to later, for example in error messages.
Synopsis
- data Delta
- = Columns !Int64 !Int64
- | Tab !Int64 !Int64 !Int64
- | Lines !Int64 !Int64 !Int64 !Int64
- | Directed !ByteString !Int64 !Int64 !Int64 !Int64
- class HasDelta t where
- class HasBytes t where
- bytes :: t -> Int64
- prettyDelta :: Delta -> Doc AnsiStyle
- nextTab :: Int64 -> Int64
- rewind :: Delta -> Delta
- near :: (HasDelta s, HasDelta t) => s -> t -> Bool
- column :: HasDelta t => t -> Int64
- columnByte :: Delta -> Int64
Documentation
Since there are multiple ways to be at a certain location, Delta captures
all these alternatives as a single type.
Constructors
| Columns !Int64 !Int64 | ( number of characters , number of bytes ) |
| Tab !Int64 !Int64 !Int64 | ( number of characters before the tab , number of characters after the tab , number of bytes ) |
| Lines !Int64 !Int64 !Int64 !Int64 | ( number of newlines contained , number of characters since the last newline , number of bytes , number of bytes since the last newline ) |
| Directed !ByteString !Int64 !Int64 !Int64 !Int64 | ( current file name , number of lines since the last line directive , number of characters since the last newline , number of bytes , number of bytes since the last newline ) |
Instances
| Eq Delta Source # | |
| Data Delta Source # | |
Defined in Text.Trifecta.Delta Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Delta -> c Delta gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Delta dataTypeOf :: Delta -> DataType dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Delta) dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Delta) gmapT :: (forall b. Data b => b -> b) -> Delta -> Delta gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Delta -> r gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Delta -> r gmapQ :: (forall d. Data d => d -> u) -> Delta -> [u] gmapQi :: Int -> (forall d. Data d => d -> u) -> Delta -> u gmapM :: Monad m => (forall d. Data d => d -> m d) -> Delta -> m Delta gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Delta -> m Delta gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Delta -> m Delta | |
| Ord Delta Source # | |
| Show Delta Source # | |
| Generic Delta Source # | |
| Semigroup Delta Source # | |
| Monoid Delta Source # | |
| Hashable Delta Source # | |
Defined in Text.Trifecta.Delta | |
| HasDelta Delta Source # | |
| HasBytes Delta Source # | |
Defined in Text.Trifecta.Delta | |
| Measured Delta Rope Source # | |
| Measured Delta Strand Source # | |
| MarkParsing Delta Parser Source # | |
| type Rep Delta Source # | |
Defined in Text.Trifecta.Delta type Rep Delta = D1 ('MetaData "Delta" "Text.Trifecta.Delta" "trifecta-2.1-Df30Vx9iHN79TDdR1k55my" 'False) ((C1 ('MetaCons "Columns" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Int64) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Int64)) :+: C1 ('MetaCons "Tab" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Int64) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Int64) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Int64)))) :+: (C1 ('MetaCons "Lines" 'PrefixI 'False) ((S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Int64) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Int64)) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Int64) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Int64))) :+: C1 ('MetaCons "Directed" 'PrefixI 'False) ((S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ByteString) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Int64)) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Int64) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Int64) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Int64)))))) | |
class HasDelta t where Source #
Instances
| HasDelta Char Source # | |
Defined in Text.Trifecta.Delta | |
| HasDelta Word8 Source # | |
Defined in Text.Trifecta.Delta | |
| HasDelta ByteString Source # | |
Defined in Text.Trifecta.Delta Methods delta :: ByteString -> Delta Source # | |
| HasDelta Delta Source # | |
| HasDelta Rope Source # | |
| HasDelta Strand Source # | |
| HasDelta Rendering Source # | |
| HasDelta Caret Source # | |
| HasDelta HighlightedRope Source # | |
Defined in Text.Trifecta.Highlight Methods delta :: HighlightedRope -> Delta Source # | |
| HasDelta (Careted a) Source # | |
| HasDelta (Rendered a) Source # | |
| (HasDelta l, HasDelta r) => HasDelta (Either l r) Source # | |
Defined in Text.Trifecta.Delta | |
| (Measured v a, HasDelta v) => HasDelta (FingerTree v a) Source # | |
Defined in Text.Trifecta.Delta Methods delta :: FingerTree v a -> Delta Source # | |
class HasBytes t where Source #
Instances
| HasBytes ByteString Source # | |
Defined in Text.Trifecta.Delta Methods bytes :: ByteString -> Int64 Source # | |
| HasBytes Delta Source # | |
Defined in Text.Trifecta.Delta | |
| HasBytes Rope Source # | |
Defined in Text.Trifecta.Rope | |
| HasBytes Strand Source # | |
Defined in Text.Trifecta.Rope | |
| HasBytes Caret Source # | |
Defined in Text.Trifecta.Rendering | |
| HasBytes HighlightedRope Source # | |
Defined in Text.Trifecta.Highlight Methods bytes :: HighlightedRope -> Int64 Source # | |
| HasBytes (Careted a) Source # | |
Defined in Text.Trifecta.Rendering | |
| HasBytes (Rendered a) Source # | |
Defined in Text.Trifecta.Rendering | |
| (Measured v a, HasBytes v) => HasBytes (FingerTree v a) Source # | |
Defined in Text.Trifecta.Delta Methods bytes :: FingerTree v a -> Int64 Source # | |
near :: (HasDelta s, HasDelta t) => s -> t -> Bool Source #
Should we show two things with a Delta on the same line?
>>>near (Columns 0 0) (Columns 5 5)True
>>>near (Lines 1 0 1 0) (Lines 2 4 4 2)False
column :: HasDelta t => t -> Int64 Source #
Retrieve the character offset within the current line from this Delta.
columnByte :: Delta -> Int64 Source #
Retrieve the byte offset within the current line from this Delta.