-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Utilities for tracking source locations -- -- Forked from part of the prosidy package. @package pro-source @version 0.1.0.0 module ProSource.Offset -- | An offset into a Source, counted by UTF-8 codepoint. newtype Offset Offset :: Word -> Offset instance GHC.Enum.Enum ProSource.Offset.Offset instance Control.DeepSeq.NFData ProSource.Offset.Offset instance Data.Hashable.Class.Hashable ProSource.Offset.Offset instance GHC.Generics.Generic ProSource.Offset.Offset instance GHC.Classes.Ord ProSource.Offset.Offset instance GHC.Show.Show ProSource.Offset.Offset instance GHC.Classes.Eq ProSource.Offset.Offset instance Prettyprinter.Internal.Pretty ProSource.Offset.Offset instance Data.Vector.Generic.Mutable.Base.MVector Data.Vector.Unboxed.Base.MVector ProSource.Offset.Offset instance Data.Vector.Generic.Base.Vector Data.Vector.Unboxed.Base.Vector ProSource.Offset.Offset instance Data.Vector.Unboxed.Base.Unbox ProSource.Offset.Offset module ProSource.Line -- | A line number. -- -- The Show instance for Line counts from one, while the -- internal implementation counts from zero. newtype Line Line :: Word -> Line instance GHC.Enum.Enum ProSource.Line.Line instance Control.DeepSeq.NFData ProSource.Line.Line instance Data.Hashable.Class.Hashable ProSource.Line.Line instance GHC.Show.Show ProSource.Line.Line instance GHC.Generics.Generic ProSource.Line.Line instance GHC.Classes.Ord ProSource.Line.Line instance GHC.Classes.Eq ProSource.Line.Line instance Prettyprinter.Internal.Pretty ProSource.Line.Line module ProSource.Column -- | A column number. newtype Column Column :: Word -> Column instance GHC.Enum.Enum ProSource.Column.Column instance Control.DeepSeq.NFData ProSource.Column.Column instance Data.Hashable.Class.Hashable ProSource.Column.Column instance GHC.Show.Show ProSource.Column.Column instance GHC.Generics.Generic ProSource.Column.Column instance GHC.Classes.Ord ProSource.Column.Column instance GHC.Classes.Eq ProSource.Column.Column instance Prettyprinter.Internal.Pretty ProSource.Column.Column module ProSource.Units module ProSource.LineMap -- | A dense vector containing offsets poiting to the start of each line. -- That is, the starting position of the third line of a file can be -- found at position 2. data LineMap -- | Convert a LineMap into a list of Offsets, corresponding -- to the first character of a line. Note that the initial offset is -- omitted-- the offset at index 0 will be the offset of the -- second line. lineOffsets :: LineMap -> [Offset] -- | Fetch the Offset for the given Line. Evaluates to -- Nothing if the given Line does not appear in the LineMap lineToOffset :: Line -> LineMap -> Maybe Offset -- | Fetch the Line number for a given Offset. Newlines will -- be attributed the line that they terminate, rather than the line -- started immediately afterwards. offsetToLine :: Offset -> LineMap -> Line fromOffsets :: Foldable f => f Offset -> LineMap instance Control.DeepSeq.NFData ProSource.LineMap.LineMap instance GHC.Show.Show ProSource.LineMap.LineMap instance GHC.Generics.Generic ProSource.LineMap.LineMap instance GHC.Classes.Eq ProSource.LineMap.LineMap instance Data.Hashable.Class.Hashable ProSource.LineMap.LineMap module ProSource.Source -- | Information about a source file. -- -- The Show instance for ths class does not include the -- LineMap or Text fields, as those are rather noisy. data Source Source :: String -> Text -> LineMap -> Source -- | The reported file-name of the Source. -- -- When read from file handles, a non-filepath description such as -- "<stdin>" is typically chosen. This field doesn't have -- semantic meaning, and should only be used to enrich the output -- displayed to users. [sourceName] :: Source -> String -- | The full source, as Text. [sourceText] :: Source -> Text -- | A mapping of the start position of each line in the Source. [sourceLineMap] :: Source -> LineMap instance Control.DeepSeq.NFData ProSource.Source.Source instance Data.Hashable.Class.Hashable ProSource.Source.Source instance GHC.Generics.Generic ProSource.Source.Source instance GHC.Classes.Eq ProSource.Source.Source instance GHC.Show.Show ProSource.Source.Source instance Prettyprinter.Internal.Pretty ProSource.Source.Source module ProSource.SparseLocation -- | A location in a Source. The line and column numbers of this -- type are not attached to this type; convert to a Location to -- access those values. data SparseLocation SparseLocation :: Source -> Offset -> SparseLocation -- | The Source this location references. [sparseLocationSource] :: SparseLocation -> Source -- | The position in the Source, counted by Unicode codepoints. [sparseLocationOffset] :: SparseLocation -> Offset instance Data.Hashable.Class.Hashable ProSource.SparseLocation.SparseLocation instance Control.DeepSeq.NFData ProSource.SparseLocation.SparseLocation instance GHC.Classes.Eq ProSource.SparseLocation.SparseLocation instance GHC.Generics.Generic ProSource.SparseLocation.SparseLocation instance GHC.Show.Show ProSource.SparseLocation.SparseLocation module ProSource.Location -- | A location in a Source, with the line and column number -- computed lazily. data Location Location :: Source -> Offset -> ~Line -> ~Column -> Location -- | The Source this location references. [locationSource] :: Location -> Source -- | The position in the Source, counted by Unicode codepoints. [locationOffset] :: Location -> Offset -- | The line number in the Source. [locationLine] :: Location -> ~Line -- | The column number in the Source. [locationColumn] :: Location -> ~Column instance Data.Hashable.Class.Hashable ProSource.Location.Location instance Control.DeepSeq.NFData ProSource.Location.Location instance GHC.Classes.Eq ProSource.Location.Location instance GHC.Generics.Generic ProSource.Location.Location instance GHC.Show.Show ProSource.Location.Location instance Prettyprinter.Internal.Pretty ProSource.Location.Location module ProSource.LocationOps -- | Add lazily computed line and column number information to a -- SparseLocation. enrichLocation :: SparseLocation -> Location -- | Remove line and column number information from a Location. stripLocation :: Location -> SparseLocation -- | An isomorphism between Location and SparseLocation. This -- is allowed because although a Location has strictly more data -- than a SparseLocation, those values are denormalizations of -- values within SparseLocation. sparse :: Iso' Location SparseLocation module ProSource.SourceOps -- | Create a Source from a descriptive name and a body. The source -- name is typically a FilePath, but this is not guaranteed. For -- instance, when read from standard-input, a common choice is to name -- the source <stdin>. makeSource :: String -> LText -> Source -- | Convert an Offset into a Location. getLocation :: Offset -> Source -> Maybe Location -- | Fetch a single line from a source. getSourceLine :: Line -> Source -> Maybe Text module ProSource.HasLocation -- | A classy optic for selecting the Location from a value. Note -- that location is affine: a Location can't be attached to -- a value which does not -- already have one, and not all values with an -- instance of HasLocation have a location. class HasLocation t location :: HasLocation t => AffineTraversal' t Location -- | Focus on the Offset from a value parsed from a source file. If -- the Offset is modified, note that the resulting column -- and line will also be modified as they are -- denormalizations of this value. offset :: HasLocation l => AffineTraversal' l Offset -- | Fetch the Column from a value parsed from a source file. -- Modifications are not allowed as the offset and line may -- become inconsistent. column :: HasLocation l => AffineFold l Column -- | Fetch the Line from a value parsed from a source file. -- Modifications are not allowed as the offset and column -- may become inconsistent. line :: HasLocation l => AffineFold l Line -- | Fetch the Source a value was parsed from. Modifications are not -- allowed as the line, offset, and column may -- become inconsistent. source :: HasLocation l => AffineFold l Source instance ProSource.HasLocation.HasLocation ProSource.Location.Location module ProSource -- | Information about a source file. -- -- The Show instance for ths class does not include the -- LineMap or Text fields, as those are rather noisy. data Source Source :: String -> Text -> LineMap -> Source -- | The reported file-name of the Source. -- -- When read from file handles, a non-filepath description such as -- "<stdin>" is typically chosen. This field doesn't have -- semantic meaning, and should only be used to enrich the output -- displayed to users. [sourceName] :: Source -> String -- | The full source, as Text. [sourceText] :: Source -> Text -- | A mapping of the start position of each line in the Source. [sourceLineMap] :: Source -> LineMap -- | Create a Source from a descriptive name and a body. The source -- name is typically a FilePath, but this is not guaranteed. For -- instance, when read from standard-input, a common choice is to name -- the source <stdin>. makeSource :: String -> LText -> Source -- | Fetch a single line from a source. getSourceLine :: Line -> Source -> Maybe Text -- | Convert an Offset into a Location. getLocation :: Offset -> Source -> Maybe Location -- | A location in a Source, with the line and column number -- computed lazily. data Location Location :: Source -> Offset -> ~Line -> ~Column -> Location -- | The Source this location references. [locationSource] :: Location -> Source -- | The position in the Source, counted by Unicode codepoints. [locationOffset] :: Location -> Offset -- | The line number in the Source. [locationLine] :: Location -> ~Line -- | The column number in the Source. [locationColumn] :: Location -> ~Column -- | A location in a Source. The line and column numbers of this -- type are not attached to this type; convert to a Location to -- access those values. data SparseLocation SparseLocation :: Source -> Offset -> SparseLocation -- | The Source this location references. [sparseLocationSource] :: SparseLocation -> Source -- | The position in the Source, counted by Unicode codepoints. [sparseLocationOffset] :: SparseLocation -> Offset -- | Add lazily computed line and column number information to a -- SparseLocation. enrichLocation :: SparseLocation -> Location -- | Remove line and column number information from a Location. stripLocation :: Location -> SparseLocation -- | An isomorphism between Location and SparseLocation. This -- is allowed because although a Location has strictly more data -- than a SparseLocation, those values are denormalizations of -- values within SparseLocation. sparse :: Iso' Location SparseLocation -- | An offset into a Source, counted by UTF-8 codepoint. newtype Offset Offset :: Word -> Offset -- | A line number. -- -- The Show instance for Line counts from one, while the -- internal implementation counts from zero. newtype Line Line :: Word -> Line -- | A column number. newtype Column Column :: Word -> Column -- | A dense vector containing offsets poiting to the start of each line. -- That is, the starting position of the third line of a file can be -- found at position 2. data LineMap -- | Convert a LineMap into a list of Offsets, corresponding -- to the first character of a line. Note that the initial offset is -- omitted-- the offset at index 0 will be the offset of the -- second line. lineOffsets :: LineMap -> [Offset] -- | Fetch the Offset for the given Line. Evaluates to -- Nothing if the given Line does not appear in the LineMap lineToOffset :: Line -> LineMap -> Maybe Offset -- | Fetch the Line number for a given Offset. Newlines will -- be attributed the line that they terminate, rather than the line -- started immediately afterwards. offsetToLine :: Offset -> LineMap -> Line -- | A classy optic for selecting the Location from a value. Note -- that location is affine: a Location can't be attached to -- a value which does not -- already have one, and not all values with an -- instance of HasLocation have a location. class HasLocation t location :: HasLocation t => AffineTraversal' t Location -- | Focus on the Offset from a value parsed from a source file. If -- the Offset is modified, note that the resulting column -- and line will also be modified as they are -- denormalizations of this value. offset :: HasLocation l => AffineTraversal' l Offset -- | Fetch the Column from a value parsed from a source file. -- Modifications are not allowed as the offset and line may -- become inconsistent. column :: HasLocation l => AffineFold l Column -- | Fetch the Line from a value parsed from a source file. -- Modifications are not allowed as the offset and column -- may become inconsistent. line :: HasLocation l => AffineFold l Line -- | Fetch the Source a value was parsed from. Modifications are not -- allowed as the line, offset, and column may -- become inconsistent. source :: HasLocation l => AffineFold l Source