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

Support full ParseResult type #26

Open
MichaelMay81 opened this issue Jan 12, 2022 · 5 comments
Open

Support full ParseResult type #26

MichaelMay81 opened this issue Jan 12, 2022 · 5 comments

Comments

@MichaelMay81
Copy link

Fable.Parsimmon supports only status and value in its ParseResult type.
parsimmon.parse returns:
{ status: true,
index: index,
value: value,
furthest: -1,
expected: []
};

I propose to use Result instead of Option for Parsimmon.parse and return "Success result.value" or "Error result"

@Zaid-Ajaj
Copy link
Owner

@MichaelMay81 sounds like a good idea! Any chance you could send a PR for this feature? It would be good to keep Parsimmon.parse and add another function Parsimmon.parseWithErrors or similar so that there aren't any breaking changes

@MichaelMay81
Copy link
Author

We are using JsonProvider for now, but we might switch to SimpleJson and than I would have time to work on this...
So for now, sadly no.

@Zaid-Ajaj
Copy link
Owner

Just curious about the use case if you don't mind sharing, why JsonProvider?

@MichaelMay81
Copy link
Author

I have to parse time series data. The first problem was the lag of exponential float format support (thx for accepting my patch) and the second the lag of error feedback. I still don't get error feedback with JsonProvider, but I get undefined parts instead of the whole parsing failing in case of errors in the json file.
So for the long term I would rather get proper error feedback in Fable.Parsimmon and Fable.SimpleJson so I can give better error feedback to the user about their data.

@Zaid-Ajaj
Copy link
Owner

The thing is with Fable.SimpleJson is that it has two ways for parsing, one by using implementing parser combinators with parsimmon and one native using JSON.parse function and transforming the result into the Json type. If you use SimpleJson.parseNative you should get proper errors when the JSON isn't correctly formatted. The next version of SimpleJson will remove the Parsimmon combinators and only leave the native ones behind.

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

2 participants