[Parsec] Extracting line and column numbers

Tomasz Zielonka t.zielonka at students.mimuw.edu.pl
Tue Jan 13 15:06:04 EST 2004

On Tue, Jan 13, 2004 at 12:44:10PM +0100, Stefan Holdermans wrote:
> Hi,
> I'm using the Parsec library to parse strings for a small experimental
> language. I'd like to decorate each node in the abstract syntax tree with
> a pair (Int, Int) that represents the line and column number in the
> strings. Unfortunately, the SourcePos class in the Parsec library is
> abstract and I cannot extract the line and column numbers from a SourcePos
> value. What are my options?

What about these?

  type Column = Int
  type Line = Int

  sourceColumn :: SourcePos -> Column
  sourceLine :: SourcePos -> Line


.signature: Too many levels of symbolic links

More information about the Haskell mailing list