-
Notifications
You must be signed in to change notification settings - Fork 51
Use ADTs for ParseError, PState and intermediate results #33
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
Use ADTs for ParseError, PState and intermediate results #33
Conversation
{ message :: String | ||
, position :: Position | ||
} | ||
data ParseError = ParseError String Position |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's hide the constructor for this in the exports list, and provide a smart constructor. We might want to add additional information here later, without breaking the API.
Thanks for this! Some of my comments are not specific to this change, but now is a good time to fix some of these issues, since we'll need a major version bump anyway. Do you mind taking a look at these? |
Thank you for the feedback, I will address all these issues. I have a question in regards to smart constructors though: I have a usecase where I need to match and construct the intermediate result since I am opening up |
@felixSchl I think there are at least a couple of good options:
I think both would be good, but we don't need to do all of this at once. |
@paf31 I have taken care of all the low hanging fruit. With the smart constructors and hiding the types, you'll have to have some patience with me. The WIP commit at the end (which I will remove from the history before we merge) reflects where I'm currently at. It currently does not build:
The only way I see around that is to add a smart constructor for |
e7098e1
to
3ee5346
Compare
@felixSchl We should be able to export This is looking good though, thanks! |
I've ported this over to my updated branch. Thanks for the PR though! |
I have seen a major speed up of neodoc after this change. For an example, the lexer processing the git branch example in the repo ran at ~ 44ms before the change, and at around ~ 14 ms after the change.
Be aware that this will break the API though as all these types are exported.