pro-source-0.1.0.0: Utilities for tracking source locations
Copyright© 2019 James Alexander Feldman-Crough
LicenseMPL-2.0
Safe HaskellNone
LanguageHaskell2010

ProSource.LineMap

Description

 
Synopsis

Documentation

data LineMap Source #

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.

Instances

Instances details
Eq LineMap Source # 
Instance details

Defined in ProSource.LineMap

Methods

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

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

Show LineMap Source # 
Instance details

Defined in ProSource.LineMap

Generic LineMap Source # 
Instance details

Defined in ProSource.LineMap

Associated Types

type Rep LineMap :: Type -> Type #

Methods

from :: LineMap -> Rep LineMap x #

to :: Rep LineMap x -> LineMap #

NFData LineMap Source # 
Instance details

Defined in ProSource.LineMap

Methods

rnf :: LineMap -> () #

Hashable LineMap Source # 
Instance details

Defined in ProSource.LineMap

Methods

hashWithSalt :: Int -> LineMap -> Int #

hash :: LineMap -> Int #

type Rep LineMap Source # 
Instance details

Defined in ProSource.LineMap

type Rep LineMap = D1 ('MetaData "LineMap" "ProSource.LineMap" "pro-source-0.1.0.0-Aka5hIIzvNFHIHVEFICznz" 'True) (C1 ('MetaCons "LineMap" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Vector Offset))))

lineOffsets :: LineMap -> [Offset] Source #

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.

lineToOffset :: Line -> LineMap -> Maybe Offset Source #

Fetch the Offset for the given Line. Evaluates to Nothing if the given Line does not appear in the LineMap

offsetToLine :: Offset -> LineMap -> Line Source #

Fetch the Line number for a given Offset. Newlines will be attributed the line that they terminate, rather than the line started immediately afterwards.