monoids-0.1.36: Monoids, specialized containers and a general map/reduce frameworkSource codeContentsIndex
Data.Monoid.Lexical.SourcePosition
Portabilitynon-portable (MPTCs, OverloadedStrings)
Stabilityexperimental
Maintainerekmett@gmail.com
Description

Incrementally determine locations in a source file through local information This allows for efficient recomputation of line #s and token locations while the file is being interactively updated by storing this as a supplemental measure on a FingerTree.

The general idea is to use this as part of a measure in a FingerTree so you can use mappend to prepend a startOfFile with the file information.

Synopsis
module Data.Monoid.Reducer.Char
nextTab :: Int -> Int
data SourcePosition file
= Pos file !SourceLine !SourceColumn
| Lines !SourceLine !SourceColumn
| Columns !SourceColumn
| Tab !SourceColumn !SourceColumn
type SourceLine = Int
type SourceColumn = Int
sourceLine :: SourcePosition f -> Maybe SourceLine
sourceColumn :: SourcePosition f -> Maybe SourceColumn
startOfFile :: f -> SourcePosition f
showSourcePosition :: SourcePosition String -> String
Documentation
module Data.Monoid.Reducer.Char
nextTab :: Int -> IntSource
Compute the location of the next standard 8-column aligned tab
data SourcePosition file Source
A Monoid of partial information about locations in a source file. This is polymorphic in the kind of information you want to maintain about each source file.
Constructors
Pos file !SourceLine !SourceColumnAn absolute position in a file is known, or an overriding #line directive has been seen
Lines !SourceLine !SourceColumnWe've seen some carriage returns.
Columns !SourceColumnWe've only seen part of a line.
Tab !SourceColumn !SourceColumnWe have an unhandled tab to deal with.
show/hide Instances
type SourceLine = IntSource
type SourceColumn = IntSource
sourceLine :: SourcePosition f -> Maybe SourceLineSource
extract partial information about the current line number if possible
sourceColumn :: SourcePosition f -> Maybe SourceColumnSource
extract partial information about the current column, even in the absence of knowledge of the source file
startOfFile :: f -> SourcePosition fSource
lift information about a source file into a starting SourcePosition for that file
showSourcePosition :: SourcePosition String -> StringSource
extract the standard format for an absolute source position
Produced by Haddock version 2.4.2