Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Expand ParseResult API #780
This is intended as a discussion issue.
Some more combinators and utility methods on
The LINQ API would allow using parse results in LINQ statements. For example something like
Filtering with a
giving a success if the parse is for a Wednesday afternoon, and a failure otherwise. The where filtering would result in some less elegant results as it would require a natural zero for
For recovery options, it would be nice to be able to fold or project the error case. Some example method signatures on
Writing these kinds of combinators isn't currently possible for users of the library, since
Is there interest in something like that? If there is, I wouldn't mind seeing if I can put that together in a working demo, so the merits of the thing can discussed with actual code behind it.
I wouldn't want to add those methods to the existing API. I think the vast majority of users would find them confusing. However, I'd be willing to look at exposing just enough that they could be built in a separate package.
Would just exposing
Come to think about it, the LINQ syntax can be quite confusing for people who associate it only with collections, which is probably almost everyone.
I'm not entirely sure yet. I only quickly went through things, and it's not actually used within the class itself, other than passing it on. I guess it's used to indicate whether to propagate the first error or replace with the last, or accumulate under some error accumulating Exception, and I would want to be consistent with the core library over being principled probably - but for that I have to dive deeper in to how it's used exactly.
Righto. Sounds like the best option is for you to explore and come up with a PR. I'm amenable to making those two methods public, possibly with an overload for