-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Library for converting between line/column and byte offset. -- -- Useful for translating visual line/column info (from editor or warning -- message) to byte offset. Assumes UTF-8. @package text-offset @version 0.1.0.0 -- | Helpers for calculating char/byte offset from line and column number. -- All line and column offsets in this module are zero-based. -- -- Note: currently only line/column to byte offset calculation is -- exposed, but the OffsetTable structure supports more, which can -- be added on demand. module Data.Text.Offset -- | Stores info for mapping line/column number (Char-based) to raw offset -- (either Char or UTF-8 encoded bytes-based). data OffsetTable -- | Calculates the OffsetTable for the given text. The table -- calculation is not optimized (non-strict tuples are lying around), but -- lookups on the result are performant (since the tuples are stored as -- unboxed vectors). createOffsetTable :: Text -> OffsetTable -- | Line and col are zero-based, col is in characters. lineColToByteOffsetDetail :: OffsetTable -> Int -> Int -> Either OffsetError Int -- | Like lineColToByteOffsetDetail, but without failure details. lineColToByteOffset :: OffsetTable -> Int -> Int -> Maybe Int data OffsetError NoSuchLine :: OffsetError EmptyLine :: OffsetError -- | Clients might want to recover from this case, see -- JustAtLineEnd. OverLineEnd :: !ByteOffset -> !OverLineKind -> OffsetError data OverLineKind -- | Referenced position is just after the line content. Position can be a -- valid non-inclusive ending span offset. JustAtLineEnd :: OverLineKind AfterLineEnd :: OverLineKind instance GHC.Show.Show Data.Text.Offset.OffsetError instance GHC.Classes.Ord Data.Text.Offset.OffsetError instance GHC.Classes.Eq Data.Text.Offset.OffsetError instance GHC.Show.Show Data.Text.Offset.OverLineKind instance GHC.Classes.Ord Data.Text.Offset.OverLineKind instance GHC.Classes.Eq Data.Text.Offset.OverLineKind instance GHC.Show.Show Data.Text.Offset.OffsetTable instance GHC.Classes.Eq Data.Text.Offset.OffsetTable