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-Inferred |
Language | Haskell2010 |
A Delta
keeps track of the cursor position of the parser, so it can be
referred to later, for example in error messages.
Documentation
Since there are multiple ways to be at a certain location, Delta
captures
all these alternatives as a single type.
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
class HasDelta t where Source #
Instances
HasDelta Word8 Source # | |
HasDelta ByteString Source # | |
Defined in Text.Trifecta.Delta delta :: ByteString -> Delta Source # | |
HasDelta Delta Source # | |
HasDelta HighlightedRope Source # | |
Defined in Text.Trifecta.Highlight delta :: HighlightedRope -> Delta Source # | |
HasDelta Caret Source # | |
HasDelta Rendering Source # | |
HasDelta Rope Source # | |
HasDelta Strand Source # | |
HasDelta Char Source # | |
HasDelta (Careted a) Source # | |
HasDelta (Rendered a) Source # | |
(HasDelta l, HasDelta r) => HasDelta (Either l r) Source # | |
(Measured v a, HasDelta v) => HasDelta (FingerTree v a) Source # | |
Defined in Text.Trifecta.Delta delta :: FingerTree v a -> Delta Source # |
class HasBytes t where Source #
Instances
HasBytes ByteString Source # | |
Defined in Text.Trifecta.Delta bytes :: ByteString -> Int64 Source # | |
HasBytes Delta Source # | |
HasBytes HighlightedRope Source # | |
Defined in Text.Trifecta.Highlight bytes :: HighlightedRope -> Int64 Source # | |
HasBytes Caret Source # | |
HasBytes Rope Source # | |
HasBytes Strand Source # | |
HasBytes (Careted a) Source # | |
HasBytes (Rendered a) Source # | |
(Measured v a, HasBytes v) => HasBytes (FingerTree v a) Source # | |
Defined in Text.Trifecta.Delta 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