Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making position a type member in parsers.scala #89

Open
smartnose opened this issue Nov 27, 2016 · 0 comments
Open

Making position a type member in parsers.scala #89

smartnose opened this issue Nov 27, 2016 · 0 comments

Comments

@smartnose
Copy link

Hi,

The parser combinators works wonderfully, except for a minor tweak I'd like to add: I would like to constrain the type of position data structure in my parser pipeline.

At the moment, parsers.scala will use the base type Position, and leave the specific position type to Readers. The downstream operation will need to perform pattern matching to cast the position data into specific type, e.g. OffsetPosition. This gets tedious if I already know that my parser will only use one specific Position type

I propose to make position a type member in a similar fashion to Elem and Input. Existing code base can be kept in-tact by adding

type Pos = Position. 

If needed, a user can constrain the position type to be more specific by overriding the type member;
e.g.

override type Pos = OffsetPosition

I will send out a pull request on the proposed change. Please take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant