| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Futhark.Profile.SourceRange
Synopsis
- data SourceRange = SourceRange {}
- startLineCol :: SourceRange -> (Int, Int)
- endLineCol :: SourceRange -> (Int, Int)
- filter123 :: (a -> Bool) -> OneTwoThree a -> Maybe (OneTwoThree a)
- overlapsWith :: SourceRange -> SourceRange -> Bool
- mergeSemigroup :: Semigroup s => (SourceRange, s) -> (SourceRange, s) -> OneTwoThree (SourceRange, s)
- parse :: Text -> Either Text SourceRange
- fileName :: SourceRange -> FilePath
Documentation
data SourceRange Source #
I chose this representation over Loc from srcLoc because it guarantees the presence of a range.
Loc is essentially a 'Maybe (Pos, Pos)', because of the NoLoc constructor.
I cannot even imagine dealing with cross-file ranges anyway.
Constructors
| SourceRange | |
Instances
| Show SourceRange Source # | |
Defined in Futhark.Profile.SourceRange Methods showsPrec :: Int -> SourceRange -> ShowS # show :: SourceRange -> String # showList :: [SourceRange] -> ShowS # | |
| Eq SourceRange Source # | |
Defined in Futhark.Profile.SourceRange | |
| Ord SourceRange Source # | |
Defined in Futhark.Profile.SourceRange Methods compare :: SourceRange -> SourceRange -> Ordering # (<) :: SourceRange -> SourceRange -> Bool # (<=) :: SourceRange -> SourceRange -> Bool # (>) :: SourceRange -> SourceRange -> Bool # (>=) :: SourceRange -> SourceRange -> Bool # max :: SourceRange -> SourceRange -> SourceRange # min :: SourceRange -> SourceRange -> SourceRange # | |
startLineCol :: SourceRange -> (Int, Int) Source #
Extract start line and column
endLineCol :: SourceRange -> (Int, Int) Source #
Extract end line and column
overlapsWith :: SourceRange -> SourceRange -> Bool Source #
mergeSemigroup :: Semigroup s => (SourceRange, s) -> (SourceRange, s) -> OneTwoThree (SourceRange, s) Source #
Assumes that the ranges overlap
parse :: Text -> Either Text SourceRange Source #
Parse a source range, respect the invariants noted in the definition and print the MegaParsec errorbundle into a Text.
>>>parse "example.fut:1:1-5"Right (SourceRange {start = Pos "example.fut" 1 1 (-1), endLine = 1, endColumn = 5})
>>>parse "directory/example.fut:15:12-17:1"Right (SourceRange {start = Pos "directory/example.fut" 15 12 (-1), endLine = 17, endColumn = 1})
fileName :: SourceRange -> FilePath Source #