ghcitui-0.3.0.0: A Terminal User Interface (TUI) for GHCi
Safe HaskellSafe-Inferred
LanguageHaskell2010

Ghcitui.Loc

Synopsis

Code locations within a file

data SourceRange Source #

Represents a multi-line range from one character to another in a source file.

Constructors

SourceRange 

Fields

class HasSourceRange a where Source #

Methods

sourceRange :: a -> SourceRange Source #

Retrieve the source range from this source location.

Instances

Instances details
HasSourceRange FileLoc Source # 
Instance details

Defined in Ghcitui.Loc

HasSourceRange ModuleLoc Source # 
Instance details

Defined in Ghcitui.Loc

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.

type ColumnRange = (Maybe Int, Maybe Int) Source #

Range, mapping start to end.

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 FileLocs are easier to manage.

data FileLoc Source #

Location in a file (may not have a corresponding module).

Constructors

FileLoc 

Instances

Instances details
Show FileLoc Source # 
Instance details

Defined in Ghcitui.Loc

Eq FileLoc Source # 
Instance details

Defined in Ghcitui.Loc

Methods

(==) :: FileLoc -> FileLoc -> Bool #

(/=) :: FileLoc -> FileLoc -> Bool #

Ord FileLoc Source # 
Instance details

Defined in Ghcitui.Loc

HasSourceRange FileLoc Source # 
Instance details

Defined in Ghcitui.Loc

data ModuleLoc Source #

Location in a module (may not have a corresponding source file).

Constructors

ModuleLoc 

Instances

Instances details
Show ModuleLoc Source # 
Instance details

Defined in Ghcitui.Loc

Eq ModuleLoc Source # 
Instance details

Defined in Ghcitui.Loc

Ord ModuleLoc Source # 
Instance details

Defined in Ghcitui.Loc

HasSourceRange ModuleLoc Source # 
Instance details

Defined in Ghcitui.Loc

Converting between modules and source files

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.