Position line and column should start at zero
jamesdbrock opened this issue · 2 comments
Position line and column should start at 0, not 1.
This has been super inconvenient for me on several occasions.
https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html
This would be an easy change to make, but the hard part would be not breaking downstream dependents.
Actually what would be better is to add a field to Position
initialPos = Position { line: 1, column: 1, offset: 0 }so then we can track both the lines-based and offset-based positions.
From an API perspective, it is too easy for a library user to construct this Position with an invalid state.
On the other hand, it was already easy for the library user to construct an invalid state, since for each line
of input, a different range of columns is valid.
Perhaps it would be better to instead add
newtype Offset = Offset Int
initialOffset = Offset 0
offset :: forall s m. Monad m => ParserT s m OffsetThanks for opening this issue @jamesdbrock. I’m not personally familiar with the background behind why this library starts at 1, so I’m going to defer to other maintainers on that. But just wanted to let you know this was seen!