Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data SourceRange = SourceRange {}
- class HasSourceRange a where
- sourceRange :: a -> SourceRange
- unknownSourceRange :: SourceRange
- isLineInside :: SourceRange -> Int -> Bool
- srFromLineNo :: Int -> SourceRange
- singleify :: SourceRange -> Maybe (Int, ColumnRange)
- type ColumnRange = (Maybe Int, Maybe Int)
- data FileLoc = FileLoc {
- filepath :: !FilePath
- fSourceRange :: !SourceRange
- data ModuleLoc = ModuleLoc {
- modName :: !Text
- mSourceRange :: !SourceRange
- toModuleLoc :: ModuleFileMap -> FileLoc -> Maybe ModuleLoc
- toFileLoc :: ModuleFileMap -> ModuleLoc -> Maybe FileLoc
- data ModuleFileMap
- moduleFileMapFromList :: [(Text, FilePath)] -> ModuleFileMap
- moduleFileMapAssocs :: ModuleFileMap -> [(Text, FilePath)]
- getPathOfModule :: ModuleFileMap -> Text -> Maybe FilePath
- getModuleOfPath :: ModuleFileMap -> FilePath -> Maybe Text
Code locations within a file
data SourceRange Source #
Represents a multi-line range from one character to another in a source file.
Instances
Show SourceRange Source # | |
Defined in Ghcitui.Loc showsPrec :: Int -> SourceRange -> ShowS # show :: SourceRange -> String # showList :: [SourceRange] -> ShowS # | |
Eq SourceRange Source # | |
Defined in Ghcitui.Loc (==) :: SourceRange -> SourceRange -> Bool # (/=) :: SourceRange -> SourceRange -> Bool # | |
Ord SourceRange Source # | |
Defined in Ghcitui.Loc compare :: SourceRange -> SourceRange -> Ordering # (<) :: SourceRange -> SourceRange -> Bool # (<=) :: SourceRange -> SourceRange -> Bool # (>) :: SourceRange -> SourceRange -> Bool # (>=) :: SourceRange -> SourceRange -> Bool # max :: SourceRange -> SourceRange -> SourceRange # min :: SourceRange -> SourceRange -> SourceRange # |
class HasSourceRange a where Source #
sourceRange :: a -> SourceRange Source #
Retrieve the source range from this source location.
Instances
HasSourceRange FileLoc Source # | |
Defined in Ghcitui.Loc sourceRange :: FileLoc -> SourceRange Source # | |
HasSourceRange ModuleLoc Source # | |
Defined in Ghcitui.Loc sourceRange :: ModuleLoc -> SourceRange Source # |
unknownSourceRange :: SourceRange Source #
A source range that represents an unknown location.
isLineInside :: SourceRange -> Int -> Bool Source #
Return whether a given line number lies within a given source range.
>>>
let sr = (srFromLineNo 1) { endLine = 3 }
>>>
isLineInside sr <$> [0, 1, 2, 3, 5]
[False, True, True, True, False]
srFromLineNo :: Int -> SourceRange Source #
Create a source range from a single line number.
singleify :: SourceRange -> Maybe (Int, ColumnRange) Source #
Convert a SourceRange
to potentially a single line and ColumnRange
.
Code in files and modules
GHCi talks about code ranges in both files and modules inconsistently. ModuleLoc
and
FileLoc
are types representing each code range. In general, locations as FileLoc
s
are easier to manage.
Location in a file (may not have a corresponding module).
FileLoc | |
|
Location in a module (may not have a corresponding source file).
ModuleLoc | |
|
Instances
Show ModuleLoc Source # | |
Eq ModuleLoc Source # | |
Ord ModuleLoc Source # | |
Defined in Ghcitui.Loc | |
HasSourceRange ModuleLoc Source # | |
Defined in Ghcitui.Loc sourceRange :: ModuleLoc -> SourceRange Source # |
toModuleLoc :: ModuleFileMap -> FileLoc -> Maybe ModuleLoc Source #
Converting between modules and source files
data ModuleFileMap Source #
Instances
Monoid ModuleFileMap Source # | |
Defined in Ghcitui.Loc mempty :: ModuleFileMap # mappend :: ModuleFileMap -> ModuleFileMap -> ModuleFileMap # mconcat :: [ModuleFileMap] -> ModuleFileMap # | |
Semigroup ModuleFileMap Source # | |
Defined in Ghcitui.Loc (<>) :: ModuleFileMap -> ModuleFileMap -> ModuleFileMap # sconcat :: NonEmpty ModuleFileMap -> ModuleFileMap # stimes :: Integral b => b -> ModuleFileMap -> ModuleFileMap # | |
Show ModuleFileMap Source # | |
Defined in Ghcitui.Loc showsPrec :: Int -> ModuleFileMap -> ShowS # show :: ModuleFileMap -> String # showList :: [ModuleFileMap] -> ShowS # | |
Eq ModuleFileMap Source # | |
Defined in Ghcitui.Loc (==) :: ModuleFileMap -> ModuleFileMap -> Bool # (/=) :: ModuleFileMap -> ModuleFileMap -> Bool # |
moduleFileMapFromList :: [(Text, FilePath)] -> ModuleFileMap Source #
Create a ModuleFileMap
from an association list.
moduleFileMapAssocs :: ModuleFileMap -> [(Text, FilePath)] Source #
Return mappings between a module name and a filepath.
getPathOfModule :: ModuleFileMap -> Text -> Maybe FilePath Source #
Convert a module to a FilePath
.
getModuleOfPath :: ModuleFileMap -> FilePath -> Maybe Text Source #
Convert a FilePath
to a module name.